diff options
author | Álvaro Brey <alvaro.brey@nextcloud.com> | 2022-08-11 18:09:04 +0300 |
---|---|---|
committer | Álvaro Brey <alvaro.brey@nextcloud.com> | 2022-08-19 14:05:20 +0300 |
commit | 1a4aaf52241be2c45e2e28fc598b34bc8f3dc8f8 (patch) | |
tree | 93b06e860dfda6e45c03a8cb006531a9a6861b85 | |
parent | 71fb20b5247127354de4d82c1e186b9f33939903 (diff) |
SharedListFragment: replace file in adapter when fetching the complete datafix/shared-selection
This fixes bugs with selection
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
-rw-r--r-- | app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java | 23 | ||||
-rw-r--r-- | app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java index 2d6b6440ff..c07d9e5652 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java @@ -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)); + } + } } diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt b/app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt index 102a400619..9ff9f5f7a5 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt @@ -101,6 +101,8 @@ class SharedListFragment : OCFileListFragment(), Injectable { isSharedWithSharee = partialFile.isSharedWithSharee sharees = partialFile.sharees } + adapter.replaceFileByRemotePath(savedFile, false) + savedFile } } } |