Why does onCrimeUpdated pass in "crime" as an argument?


In listing 22.13, onCrimeUpdated takes one argument: “Crime crime.” Why?

onCrimeUpdated doesn’t seem to do anything with the crime parameter. I deleted it from the method’s arguments list (and removed mCrime from wherever the method is called), and the app behaves exactly the same.


It’s not used in the code in the book, but we thought it would be discourteous to say that a crime was updated without saying which crime was updated.

If you’re interested, it’s also possible to use the Crime object from the event to perform a more fine-grained update than notifyDataSetChanged’s “refresh everything” update. Just iterate through the currently visible items on your AdapterView, and if you find that your Crime is currently visible, update its view by calling getAdapter.getView() by hand, making sure to pass in the current view as the convertView parameter.


Awesome, thanks for the thorough and interesting answer. (The book is fantastic, btw!)