@@ -56,7 +56,7 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
5656
5757 private static final int MINIMUM_INITIAL_DRAG_VELOCITY = 12 ;
5858 @ State
59- protected Parcelable itemsListState ;
59+ Parcelable itemsListState ;
6060
6161 private Subscription databaseSubscription ;
6262 private CompositeDisposable disposables = new CompositeDisposable ();
@@ -68,6 +68,7 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
6868 private AtomicBoolean isLoadingComplete ;
6969
7070 /* Gives enough time to avoid interrupting user sorting operations */
71+ @ Nullable
7172 private DebounceSaver debounceSaver ;
7273
7374 private List <Pair <Long , LocalItem .LocalItemType >> deletedItems ;
@@ -259,7 +260,6 @@ public void onSubscribe(final Subscription s) {
259260 @ Override
260261 public void onNext (final List <PlaylistLocalItem > subscriptions ) {
261262 if (debounceSaver == null || !debounceSaver .getIsModified ()) {
262- checkDisplayIndexModified (subscriptions );
263263 handleResult (subscriptions );
264264 isLoadingComplete .set (true );
265265 }
@@ -349,30 +349,9 @@ private void deleteItem(final PlaylistLocalItem item) {
349349 LocalItem .LocalItemType .PLAYLIST_REMOTE_ITEM ));
350350 }
351351
352- debounceSaver .setHasChangesToSave ();
353- }
354-
355- private void checkDisplayIndexModified (@ NonNull final List <PlaylistLocalItem > result ) {
356- if (debounceSaver != null && debounceSaver .getIsModified ()) {
357- return ;
358- }
359-
360- // Check if the display index does not match the actual index in the list.
361- // This may happen when a new list is created
362- // or on the first run after database migration
363- // or display index is not continuous for some reason
364- // or the user changes the display index.
365- boolean isDisplayIndexModified = false ;
366- for (int i = 0 ; i < result .size (); i ++) {
367- final PlaylistLocalItem item = result .get (i );
368- if (item .getDisplayIndex () != i ) {
369- isDisplayIndexModified = true ;
370- break ;
371- }
372- }
373-
374- if (debounceSaver != null && isDisplayIndexModified ) {
352+ if (debounceSaver != null ) {
375353 debounceSaver .setHasChangesToSave ();
354+ saveImmediate ();
376355 }
377356 }
378357
@@ -482,7 +461,7 @@ public boolean onMove(@NonNull final RecyclerView recyclerView,
482461 final int sourceIndex = source .getBindingAdapterPosition ();
483462 final int targetIndex = target .getBindingAdapterPosition ();
484463 final boolean isSwapped = itemListAdapter .swapItems (sourceIndex , targetIndex );
485- if (isSwapped ) {
464+ if (isSwapped && debounceSaver != null ) {
486465 debounceSaver .setHasChangesToSave ();
487466 }
488467 return isSwapped ;
0 commit comments