Sfoglia il codice sorgente

Remove onAccountSet from image and video preview activities

Both callbacks are directly called from onStart().
Since callback parameter is unused, inline the
callback code in onStart().

Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
Chris Narkiewicz 5 anni fa
parent
commit
b199a62b78

+ 28 - 33
src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -183,6 +183,34 @@ public class PreviewImageActivity extends FileActivity implements
     @Override
     public void onStart() {
         super.onStart();
+        if (getAccount() != null) {
+            OCFile file = getFile();
+            /// Validate handled file (first image to preview)
+            if (file == null) {
+                throw new IllegalStateException("Instanced with a NULL OCFile");
+            }
+            if (!MimeTypeUtil.isImage(file)) {
+                throw new IllegalArgumentException("Non-image file passed as argument");
+            }
+
+            // Update file according to DB file, if it is possible
+            if (file.getFileId() > FileDataStorageManager.ROOT_PARENT_ID) {
+                file = getStorageManager().getFileById(file.getFileId());
+            }
+
+            if (file != null) {
+                /// Refresh the activity according to the Account and OCFile set
+                setFile(file);  // reset after getting it fresh from storageManager
+                getSupportActionBar().setTitle(getFile().getFileName());
+                //if (!stateWasRecovered) {
+                initViewPager();
+                //}
+
+            } else {
+                // handled file not in the current Account
+                finish();
+            }
+        }
     }
 
     @Override
@@ -507,39 +535,6 @@ public class PreviewImageActivity extends FileActivity implements
         hideSystemUI(mFullScreenAnchorView);
     }
 
-    @Override
-    protected void onAccountSet(boolean stateWasRecovered) {
-        super.onAccountSet(stateWasRecovered);
-        if (getAccount() != null) {
-            OCFile file = getFile();
-            /// Validate handled file (first image to preview)
-            if (file == null) {
-                throw new IllegalStateException("Instanced with a NULL OCFile");
-            }
-            if (!MimeTypeUtil.isImage(file)) {
-                throw new IllegalArgumentException("Non-image file passed as argument");
-            }
-
-            // Update file according to DB file, if it is possible
-            if (file.getFileId() > FileDataStorageManager.ROOT_PARENT_ID) {
-                file = getStorageManager().getFileById(file.getFileId());
-            }
-
-            if (file != null) {
-                /// Refresh the activity according to the Account and OCFile set
-                setFile(file);  // reset after getting it fresh from storageManager
-                getSupportActionBar().setTitle(getFile().getFileName());
-                //if (!stateWasRecovered) {
-                    initViewPager();
-                //}
-
-            } else {
-                // handled file not in the current Account
-                finish();
-            }
-        }
-    }
-
     @Override
     public void onBrowsedDownTo(OCFile folder) {
         // TODO Auto-generated method stub

+ 2 - 2
src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java

@@ -196,8 +196,8 @@ public class PreviewVideoActivity extends FileActivity implements OnCompletionLi
     }
 
     @Override
-    protected void onAccountSet(boolean stateWasRecovered) {
-        super.onAccountSet(stateWasRecovered);
+    protected void onStart() {
+        super.onStart();
         if (getAccount() != null) {
             OCFile file = getFile();
             /// Validate handled file  (first image to preview)