SharedListFragment: replace file in adapter when fetching the complete data

This fixes bugs with selection

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-08-11 17:09:04 +02:00
parent 71fb20b524
commit 1a4aaf5224
2 changed files with 25 additions and 0 deletions

View file

@ -993,4 +993,27 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public void notifyItemChanged(@NonNull OCFile file) {
notifyItemChanged(getItemPosition(file));
}
public void replaceFileByRemotePath(@NonNull OCFile newFile, boolean notify) {
final String remotePath = newFile.getRemotePath();
for (OCFile file : mFiles) {
if (file.getRemotePath().equals(remotePath)) {
final int index = mFiles.indexOf(file);
mFiles.set(index, newFile);
break;
}
}
for (OCFile file : mFilesAll) {
if (file.getRemotePath().equals(remotePath)) {
final int index = mFilesAll.indexOf(file);
mFilesAll.set(index, newFile);
break;
}
}
if (notify) {
notifyItemChanged(getItemPosition(newFile));
}
}
}

View file

@ -101,6 +101,8 @@ class SharedListFragment : OCFileListFragment(), Injectable {
isSharedWithSharee = partialFile.isSharedWithSharee
sharees = partialFile.sharees
}
adapter.replaceFileByRemotePath(savedFile, false)
savedFile
}
}
}