Skip to content

Commit

Permalink
Make sure notifyDataSetChanged gets directly called after removing file
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Mayer <[email protected]>
  • Loading branch information
JonasMayerDev committed Jan 11, 2024
1 parent fb3694f commit 5584ef9
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,13 @@ public int getItemPosition(@NonNull OCFile file) {
}

public void setFavoriteAttributeForItemID(String remotePath, boolean favorite, boolean removeFromList) {
List<OCFile> filesToDelete = new ArrayList<>();
for (OCFile file : mFiles) {
if (file.getRemotePath().equals(remotePath)) {
file.setFavorite(favorite);

if (removeFromList) {
mFiles.remove(file);
filesToDelete.add(file);
}

break;
Expand All @@ -239,7 +240,7 @@ public void setFavoriteAttributeForItemID(String remotePath, boolean favorite, b
mStorageManager.saveFile(file);

if (removeFromList) {
mFiles.remove(file);
filesToDelete.add(file);
}

break;
Expand All @@ -255,7 +256,10 @@ public void setFavoriteAttributeForItemID(String remotePath, boolean favorite, b
mFiles = sortOrder.sortCloudFiles(mFiles);
}

new Handler(Looper.getMainLooper()).post(this::notifyDataSetChanged);
new Handler(Looper.getMainLooper()).post(() -> {
mFiles.removeAll(filesToDelete);
notifyDataSetChanged();
});
}

public void refreshCommentsCount(String fileId) {
Expand Down

0 comments on commit 5584ef9

Please sign in to comment.