Bladeren bron

Merge pull request #10391 from nextcloud/updateSharIcon

Update share icon when sharing link directly
Álvaro Brey 2 jaren geleden
bovenliggende
commit
84aa239c9a

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

@@ -87,6 +87,7 @@ import com.owncloud.android.ui.dialog.ShareLinkToDialog;
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
 import com.owncloud.android.ui.fragment.FileDetailFragment;
 import com.owncloud.android.ui.fragment.FileDetailSharingFragment;
+import com.owncloud.android.ui.fragment.OCFileListFragment;
 import com.owncloud.android.ui.helpers.FileOperationsHelper;
 import com.owncloud.android.utils.ClipboardUtil;
 import com.owncloud.android.utils.DisplayUtils;
@@ -781,6 +782,7 @@ public abstract class FileActivity extends DrawerActivity
     private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation,
                                                      RemoteOperationResult result) {
         FileDetailSharingFragment sharingFragment = getShareFileFragment();
+        OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_LIST_OF_FILES);
 
         if (result.isSuccess()) {
             updateFileFromDB();
@@ -803,6 +805,10 @@ public abstract class FileActivity extends DrawerActivity
             if (sharingFragment != null) {
                 sharingFragment.onUpdateShareInformation(result, file);
             }
+
+            if (fileListFragment != null && file != null) {
+                fileListFragment.updateOCFile(file);
+            }
         } else {
             // Detect Failure (403) --> maybe needs password
             String password = operation.getPassword();

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

@@ -1322,6 +1322,12 @@ public class OCFileListFragment extends ExtendedListFragment implements
         }
     }
 
+    public void updateOCFile(OCFile file) {
+        mAdapter.getFiles().remove(file);
+        mAdapter.getFiles().add(file);
+        mAdapter.notifyItemChanged(file);
+    }
+
     private void updateLayout() {
         // decide grid vs list view
         if (isGridViewPreferred(mFile)) {