Skip to content

Commit 5584ef9

Browse files
committed
Make sure notifyDataSetChanged gets directly called after removing file
Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
1 parent fb3694f commit 5584ef9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,13 @@ public int getItemPosition(@NonNull OCFile file) {
220220
}
221221

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

227228
if (removeFromList) {
228-
mFiles.remove(file);
229+
filesToDelete.add(file);
229230
}
230231

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

241242
if (removeFromList) {
242-
mFiles.remove(file);
243+
filesToDelete.add(file);
243244
}
244245

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

258-
new Handler(Looper.getMainLooper()).post(this::notifyDataSetChanged);
259+
new Handler(Looper.getMainLooper()).post(() -> {
260+
mFiles.removeAll(filesToDelete);
261+
notifyDataSetChanged();
262+
});
259263
}
260264

261265
public void refreshCommentsCount(String fileId) {

0 commit comments

Comments
 (0)