Chapter 12 - Challenge: Efficient RecyclerView Reloading

How I can verify if Ive implemented this challenge correctly?

The app behavior would be exactly same as before, only difference should be in internal workings of the RecycleView and its components.

Also have no idea where should I call ListAdapter.submitList. In updateUI it doesnt work (shows empty list)

Anyone was able to figure this out?

If you follow the book exactly as written, I’m unsure you can properly verify this challenge is implemented correctly. When you go to CrimeFragment, CrimeListFragment is destroyed. Upon returning to CrimeListFragment, a new view is created so visually there is no change. I’m also unsure if you measured any metrics regarding load time if you’d notice any change since a new RecyclerView is being created each time.

Here is how I verified it was working correctly, and the steps I went through:

  1. I initially skipped the Ch. 12 Challenge and went through Ch. 18.
  2. One of the sections that was removed from the 4th edition was the introduction of the two-pane layout with a List-Detail view. I implemented this for a landscape layout.
  3. When in two-pane view, upon selecting an item from the CrimeListFragment, the CrimeFragment is loaded alongside so no Fragment or View is destroyed.
  4. When the Crime details are updated, without the challenge the entire RecyclerView adapter is recreated and the entire list is reloaded. This results in the list going back to the top even if you are at the bottom of the scroll and you lose your place.
  5. Once this challenge is completed properly, now only the list item that has changed reloads and the list stays at its current scroll point. Additionally, when a Crime is deleted (another prior challenge that was removed) the list item is removed from the RecyclerView and the items clean close the gap.

I just did notice a change when in the single-pane view as written in the book. If I check the box that the crime was solved (or not), when I now return to the list the solved image fades in/out. I don’t recall noticing this previously and don’t believe I changed anything related to the RecyclerView recently.