Merge pull request #4686 from nextcloud/account-cleanup-image-video-preview

Remove onAccountSet from image and video preview activities
This commit is contained in:
Tobias Kaminsky authored and GitHub committed 2019-10-17 15:21:54 +02:00
commit d9567a2bb6
2 files changed
+30 -35

No files matched your search

@@ -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
@@ -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)