Fix sonar warning

This commit is contained in:
GGAutomaton 2022-04-16 12:44:24 +08:00
parent c24aed054f
commit bd1aae8d66
1 changed files with 6 additions and 10 deletions

View File

@ -446,12 +446,10 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
final Long databaseIndex = displayIndexInDatabase.remove(key); final Long databaseIndex = displayIndexInDatabase.remove(key);
// The database index should not be null because inserting new item into database // The database index should not be null because inserting new item into database
// is not dealt here. NullPointerException has occurred once, but I can't reproduce // is not handled here. NullPointerException has occurred once, but I can't
// it. Enhance robustness here. // reproduce it. Enhance robustness here.
if (databaseIndex != null) { if (databaseIndex != null && databaseIndex != i) {
if (databaseIndex != i) { localItemsUpdate.add((PlaylistMetadataEntry) item);
localItemsUpdate.add((PlaylistMetadataEntry) item);
}
} }
} else if (item instanceof PlaylistRemoteEntity) { } else if (item instanceof PlaylistRemoteEntity) {
((PlaylistRemoteEntity) item).setDisplayIndex(i); ((PlaylistRemoteEntity) item).setDisplayIndex(i);
@ -461,10 +459,8 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
LocalItem.LocalItemType.PLAYLIST_REMOTE_ITEM); LocalItem.LocalItemType.PLAYLIST_REMOTE_ITEM);
final Long databaseIndex = displayIndexInDatabase.remove(key); final Long databaseIndex = displayIndexInDatabase.remove(key);
if (databaseIndex != null) { if (databaseIndex != null && databaseIndex != i) {
if (databaseIndex != i) { remoteItemsUpdate.add((PlaylistRemoteEntity) item);
remoteItemsUpdate.add((PlaylistRemoteEntity) item);
}
} }
} }
} }