From 1373a67ea03e5fcdea034c53856b51eaead7a0c9 Mon Sep 17 00:00:00 2001 From: Alexander Bakker Date: Sat, 4 Jun 2022 18:59:45 +0200 Subject: [PATCH] Only re-sort entry list when not using custom sorting This fixes a crash introduced in #910. --- .../beemdevelopment/aegis/ui/views/EntryAdapter.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryAdapter.java b/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryAdapter.java index 0c8a151c..7da75b25 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryAdapter.java +++ b/app/src/main/java/com/beemdevelopment/aegis/ui/views/EntryAdapter.java @@ -194,10 +194,12 @@ public class EntryAdapter extends RecyclerView.Adapter implements I notifyItemChanged(position); if (_sortCategory != null) { Comparator comparator = _sortCategory.getComparator(); - Collections.sort(_shownEntries, comparator); - int newPosition = Collections.binarySearch(_shownEntries, newEntry, comparator); - if (position != newPosition) { - notifyItemMoved(position, newPosition); + if (comparator != null) { + Collections.sort(_shownEntries, comparator); + int newPosition = Collections.binarySearch(_shownEntries, newEntry, comparator); + if (position != newPosition) { + notifyItemMoved(position, newPosition); + } } } }