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);
}
public boolean hasItemPosition(int notePosition) {
return notePosition >= 0 && notePosition < itemList.size();
}
public void remove(@NonNull Item item) {
itemList.remove(item);
notifyDataSetChanged();

View file

@ -31,7 +31,10 @@ public class ItemSelectionTracker {
@Override
public boolean canSetStateAtPosition(int position, boolean nextState) {
@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

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)