radzio / android-data-binding-recyclerview

Using Recyclerview with the new Android Data Binding framework
Apache License 2.0
564 stars 97 forks source link

Bug in WeakReferenceOnListChangedCallback #9

Open m6s opened 8 years ago

m6s commented 8 years ago

Came to your project via Stackoverflow, and found a bug. You're overriding onRangeMoved(), but you're delegating to notifyItemMoved(). This is only correct if itemCount is 1.

@Override
public void onItemRangeMoved(ObservableList sender, int fromPosition, int toPosition, int itemCount)
{
      RecyclerView.Adapter adapter = adapterReference.get();
      if (adapter != null)
      {
          adapter.notifyItemMoved(fromPosition, toPosition);
      }
}