Fix #1308 Crash when long pressing a note and swiping to the edge of the screen

Signed-off-by: Stefan Niedermann <info@niedermann.it>
This commit is contained in:
Stefan Niedermann 2021-09-11 12:02:25 +02:00
parent 119fced969
commit a9fb6f12ba
3 changed files with 10 additions and 1 deletions

View file

@ -170,6 +170,10 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i
return itemList.get(notePosition); return itemList.get(notePosition);
} }
public boolean hasItemPosition(int notePosition) {
return notePosition >= 0 && notePosition < itemList.size();
}
public void remove(@NonNull Item item) { public void remove(@NonNull Item item) {
itemList.remove(item); itemList.remove(item);
notifyDataSetChanged(); notifyDataSetChanged();

View file

@ -31,7 +31,10 @@ public class ItemSelectionTracker {
@Override @Override
public boolean canSetStateAtPosition(int position, boolean nextState) { public boolean canSetStateAtPosition(int position, boolean nextState) {
@Nullable Integer swipedPosition = adapter.getSwipedPosition(); @Nullable Integer swipedPosition = adapter.getSwipedPosition();
return !adapter.getItem(position).isSection() && (swipedPosition == null || swipedPosition != position); if (!adapter.hasItemPosition(position)) {
return false;
}
return (swipedPosition == null || swipedPosition != position) && !adapter.getItem(position).isSection();
} }
@Override @Override

View file

@ -0,0 +1,2 @@
- 🐞 Fix potential crash when rendering a note with a checkbox (#1326) - by @pbek
- 🐞 Fix crash when long pressing a note and swiping to the edge of the screen (#1308)