+
+ @Override
+ protected void onAccountSet(boolean 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 (!file.isImage()) {
+ throw new IllegalArgumentException("Non-image file passed as argument");
+ }
+ mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
+
+ // Update file according to DB file, if it is possible
+ if (file.getFileId() > FileDataStorageManager.ROOT_PARENT_ID)
+ file = mStorageManager.getFileById(file.getFileId());
+
+ if (file != null) {
+ /// Refresh the activity according to the Account and OCFile set
+ setFile(file); // reset after getting it fresh from mStorageManager
+ getSupportActionBar().setTitle(getFile().getFileName());
+ //if (!stateWasRecovered) {
+ initViewPager();
+ //}
+
+ } else {
+ // handled file not in the current Account
+ finish();
+ }
+
+ } else {
+ Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+ }
+ }
+