Merge pull request #1753 from mfietz/issue/simpleanimator_npe
Fix RecyclerView reorder crash
This commit is contained in:
commit
cac5667744
|
@ -202,7 +202,8 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR
|
|||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
FeedItem item = itemAccess.getItem(position);
|
||||
return item != null ? item.getId() : RecyclerView.NO_POSITION;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -109,6 +109,12 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<QueueRecyclerAdap
|
|||
return selectedItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
FeedItem item = itemAccess.getItem(position);
|
||||
return item != null ? item.getId() : RecyclerView.NO_POSITION;
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return itemAccess.getCount();
|
||||
}
|
||||
|
|
|
@ -337,6 +337,7 @@ public class AllEpisodesFragment extends Fragment {
|
|||
MainActivity mainActivity = activity.get();
|
||||
listAdapter = new AllEpisodesRecycleAdapter(mainActivity, itemAccess,
|
||||
new DefaultActionButtonCallback(mainActivity), showOnlyNewEpisodes());
|
||||
listAdapter.setHasStableIds(true);
|
||||
recyclerView.setAdapter(listAdapter);
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
|
|
@ -474,6 +474,7 @@ public class QueueFragment extends Fragment {
|
|||
MainActivity activity = (MainActivity) getActivity();
|
||||
recyclerAdapter = new QueueRecyclerAdapter(activity, itemAccess,
|
||||
new DefaultActionButtonCallback(activity), itemTouchHelper);
|
||||
recyclerAdapter.setHasStableIds(true);
|
||||
recyclerView.setAdapter(recyclerAdapter);
|
||||
}
|
||||
if(queue == null || queue.size() == 0) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/divider"
|
||||
android:scrollbars="vertical"/>
|
||||
|
||||
|
|
Loading…
Reference in New Issue