Not seeing written behavior on page 394 using APIs above 19

Just curious, if we were to always stay above API19 would we still have to complete the coding on page 395?

1 Like

Are you talking about Listing 20.26 with the BaseObservable subclass and such?

If so, DataBinding is the same on all API levels that it supports (API level 7+). The code would not change no matter which versions you support.

1 Like

Yes, I didn’t know if performing Listing 20.26 was necessary on API’s above 19. The reason I was asking was because I tested the same code on different emulated APIs and noticed only 19 and lower displayed the “Deja vu” problem in figure 20.12.

I wasn’t sure if this problem was fixed in later APIs without the need of calling notifyChange.

1 Like

Right, but have changes in RecyclerView or data-binding related models changed in later APIs, such that we do not need for our SoundViewModel to be a BaseObservable and call notifyChange?

There haven’t been any changes to my knowledge. You should still use BaseObservable and notifyChange. Is there something that changed?

The issue is that the problem motivating the code does not manifest. Viewing the list works just fine prior to extending BaseObservable and so on. In other words, figure 20.12 never manifests.

Ah. OK, I see what you are saying.

It’s possible that there has been some change in the RecyclerView or DataBinding library where this particular issue no longer shows up. It could also be a factor of how many items are in the list and the screen size. Either way, it continues to be very important that you use BaseObservable and notifyChange when you change the data in a view model. Otherwise, the view model can’t know when to refresh the view. So, it may not be an issue in this case, but it will be an issue in many other situations.

2 Likes