Explorar o código

fix updating the (right) list item

AndyScherzinger %!s(int64=6) %!d(string=hai) anos
pai
achega
47217e7355

+ 3 - 5
src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java

@@ -240,11 +240,9 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
         setListShown(true);
 
         if (!TextUtils.isEmpty(path)) {
-            for(SyncedFolderDisplayItem syncFolderItem : syncFolderItems) {
-                if (syncFolderItem.getLocalPath().equalsIgnoreCase(path) &&
-                        syncFolderItem.getType().getId().equals(type)) {
-                    onSyncFolderSettingsClick(1, syncFolderItem);
-                }
+            int section = mAdapter.getSectionByLocalPathAndType(path, type);
+            if (section >= 0) {
+                onSyncFolderSettingsClick(section, mAdapter.get(section));
             }
         }
     }

+ 18 - 0
src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java

@@ -108,6 +108,24 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SyncedFold
         return mSyncFolderItems.get(section);
     }
 
+    /**
+     * returns the section of a synced folder for the given local path and type.
+     *
+     * @param localPath the local path of the synced folder
+     * @param type      the of the synced folder
+     * @return the section index of the looked up synced folder, <code>-1</code> if not present
+     */
+    public int getSectionByLocalPathAndType(String localPath, int type) {
+        for (int i = 0; i < mSyncFolderItems.size(); i++) {
+            if (mSyncFolderItems.get(i).getLocalPath().equalsIgnoreCase(localPath) &&
+                    mSyncFolderItems.get(i).getType().getId().equals(type)) {
+                return i;
+            }
+        }
+
+        return -1;
+    }
+
     @Override
     public void onBindHeaderViewHolder(final MainViewHolder holder, final int section, boolean expanded) {
         holder.mainHeaderContainer.setVisibility(View.VISIBLE);