From 3cc0205def80a6732ea374655a272ac7d3457503 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 30 Mar 2024 14:14:31 +0100 Subject: [PATCH] Fix inconsistencies when removing playlist Remove checkDisplayIndexModified because it was causing more problems than it solved. Now when adding new playlists they won't necessarily appear at the top, but will get sorted alphabetically along with the other playlists with index -1. This will be the case until any playlist is sorted, at which point all indices are assigned and newly added playlists will appear at the top again. --- .../local/bookmark/BookmarkFragment.java | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java index 59e2582ff..922429382 100644 --- a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java @@ -56,7 +56,7 @@ public final class BookmarkFragment extends BaseLocalListFragment> deletedItems; @@ -259,7 +260,6 @@ public final class BookmarkFragment extends BaseLocalListFragment subscriptions) { if (debounceSaver == null || !debounceSaver.getIsModified()) { - checkDisplayIndexModified(subscriptions); handleResult(subscriptions); isLoadingComplete.set(true); } @@ -349,30 +349,9 @@ public final class BookmarkFragment extends BaseLocalListFragment result) { - if (debounceSaver != null && debounceSaver.getIsModified()) { - return; - } - - // Check if the display index does not match the actual index in the list. - // This may happen when a new list is created - // or on the first run after database migration - // or display index is not continuous for some reason - // or the user changes the display index. - boolean isDisplayIndexModified = false; - for (int i = 0; i < result.size(); i++) { - final PlaylistLocalItem item = result.get(i); - if (item.getDisplayIndex() != i) { - isDisplayIndexModified = true; - break; - } - } - - if (debounceSaver != null && isDisplayIndexModified) { + if (debounceSaver != null) { debounceSaver.setHasChangesToSave(); + saveImmediate(); } } @@ -482,7 +461,7 @@ public final class BookmarkFragment extends BaseLocalListFragment