SuperRecyclerView icon indicating copy to clipboard operation
SuperRecyclerView copied to clipboard

Fixed a crash when the adapter still triggers the update of the previous recycler view

Open KelvinJin opened this issue 9 years ago • 0 comments

How to reproduce the bug:

  • Assign a non-null adapter adapter to a SuperRecyclerView instance recyclerView: recyclerView.setAdapter(adapter)
  • Assign a null adapter to the recyclerView: recyclerView.setAdapter(null).
  • Call adapter.notifyDataSetChanged().

The recyclerView will get notified since the observer is not cancelled. But now, recyclerView.getAdapter() will return null, this will crash when recyclerView.getAdapter().getCount() is called.

This PR fixed this issue by cancelling the observation once the adapter is changed. (Essentially this is how the official RecyclerView handles adapter changing.)

KelvinJin avatar Jul 21 '16 05:07 KelvinJin