OC-2927: (Fix bug) App crashes when sharing a mp3 while it's playing
authormasensio <masensio@solidgear.es>
Fri, 14 Feb 2014 09:19:52 +0000 (10:19 +0100)
committermasensio <masensio@solidgear.es>
Fri, 14 Feb 2014 09:19:52 +0000 (10:19 +0100)
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java

index 51ebded..e696352 100644 (file)
@@ -1370,16 +1370,16 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
         if (details != null) {
             OCFile file = details.getFile();
             if (file != null) {
         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();
+        } 
     }
     
     /**
     }
     
     /**
index 38251d9..336f6b9 100644 (file)
@@ -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());
     private void unshareFileWithLink() {
         stopPreview(false);
         FileActivity activity = (FileActivity)((FileFragment.ContainerActivity)getActivity());