Browse Source

Simplify logic

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 year ago
parent
commit
38d9b0f4cb

+ 2 - 2
app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java

@@ -807,8 +807,8 @@ public abstract class FileActivity extends DrawerActivity
                 sharingFragment.onUpdateShareInformation(result, file);
             }
 
-            if (fileListFragment instanceof OCFileListFragment && file != null) {
-                ((OCFileListFragment) fileListFragment).updateOCFile(file);
+            if (fileListFragment instanceof OCFileListFragment ocFileListFragment && file != null) {
+                ocFileListFragment.updateOCFile(file);
             }
         } else {
             // Detect Failure (403) --> maybe needs password

+ 3 - 3
app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -1387,14 +1387,14 @@ public class OCFileListFragment extends ExtendedListFragment implements
         }
     }
 
-    public void updateOCFile(OCFile file) {
+    public void updateOCFile(@NonNull OCFile file) {
         List<OCFile> mFiles = mAdapter.getFiles();
-        int index = mFiles.indexOf(file);
-        if (index == -1) {
+        if (!mFiles.contains(file)) {
             Log_OC.d(TAG, "File cannot be found in adapter's files");
             return;
         }
 
+        int index = mFiles.indexOf(file);
         mFiles.set(index, file);
         mAdapter.notifyItemChanged(file);
     }