Explorar o código

Merge remote-tracking branch 'origin/share_link__unshare_file' into share_link__unshare_file

David A. Velasco %!s(int64=11) %!d(string=hai) anos
pai
achega
4cc578faf9

+ 10 - 10
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1370,16 +1370,16 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
         if (details != null) {
             OCFile file = details.getFile();
             if (file != null) {
-                file = getStorageManager().getFileByPath(file.getRemotePath()); {
-                    if (!(details instanceof PreviewMediaFragment || details instanceof PreviewImageFragment)) {
-                        showDetails(file);
-                    } else if (details instanceof PreviewMediaFragment) {
-                        startMediaPreview(file, 0, false);
-                    } 
-                }
-                invalidateOptionsMenu();
-            } 
-        }
+                file = getStorageManager().getFileByPath(file.getRemotePath()); 
+                if (details instanceof PreviewMediaFragment) {
+                    // Refresh  OCFile of the fragment
+                    ((PreviewMediaFragment) details).updateFile(file);
+                } else {
+                    showDetails(file);
+                } 
+            }
+            invalidateOptionsMenu();
+        } 
     }
     
     /**

+ 21 - 11
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java

@@ -359,6 +359,14 @@ public class PreviewMediaFragment extends FileFragment implements
     
 
 
+    /**
+     * Update the file of the fragment with file value
+     * @param file
+     */
+    public void updateFile(OCFile file){
+        setFile(file);
+    }
+    
     private void unshareFileWithLink() {
         stopPreview(false);
         FileActivity activity = (FileActivity)((FileFragment.ContainerActivity)getActivity());
@@ -580,17 +588,19 @@ public class PreviewMediaFragment extends FileFragment implements
 
         @Override
         public void onServiceConnected(ComponentName component, IBinder service) {
-            if (component.equals(new ComponentName(getActivity(), MediaService.class))) {
-                Log_OC.d(TAG, "Media service connected");
-                mMediaServiceBinder = (MediaServiceBinder) service;
-                if (mMediaServiceBinder != null) {
-                    prepareMediaController();
-                    playAudio();    // do not wait for the touch of nobody to play audio
-                    
-                    Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready");
-                    
-                } else {
-                    Log_OC.e(TAG, "Unexpected response from MediaService while binding");
+            if (getActivity() != null) {
+                if (component.equals(new ComponentName(getActivity(), MediaService.class))) {
+                    Log_OC.d(TAG, "Media service connected");
+                    mMediaServiceBinder = (MediaServiceBinder) service;
+                    if (mMediaServiceBinder != null) {
+                        prepareMediaController();
+                        playAudio();    // do not wait for the touch of nobody to play audio
+
+                        Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready");
+
+                    } else {
+                        Log_OC.e(TAG, "Unexpected response from MediaService while binding");
+                    }
                 }
             }
         }