private static final String DIALOG_WAIT_TAG = "DIALOG_WAIT";
- private FileDataStorageManager mStorageManager;
-
private ViewPager mViewPager;
private PreviewImagePagerAdapter mPreviewImagePagerAdapter;
private void initViewPager() {
// get parent from path
String parentPath = getFile().getRemotePath().substring(0, getFile().getRemotePath().lastIndexOf(getFile().getFileName()));
- OCFile parentFolder = mStorageManager.getFileByPath(parentPath);
- //OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId());
+ OCFile parentFolder = getStorageManager().getFileByPath(parentPath);
if (parentFolder == null) {
// should not be necessary
- parentFolder = mStorageManager.getFileByPath(OCFile.ROOT_PATH);
+ parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
}
- mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, getAccount(), mStorageManager);
+ mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, getAccount(), getStorageManager());
mViewPager = (ViewPager) findViewById(R.id.fragmentPager);
int position = mPreviewImagePagerAdapter.getFilePosition(getFile());
position = (position >= 0) ? position : 0;
if (getAccount().name.equals(accountName) &&
downloadedRemotePath != null) {
- OCFile file = mStorageManager.getFileByPath(downloadedRemotePath);
+ OCFile file = getStorageManager().getFileByPath(downloadedRemotePath);
int position = mPreviewImagePagerAdapter.getFilePosition(file);
boolean downloadWasFine = intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false);
//boolean isOffscreen = Math.abs((mViewPager.getCurrentItem() - position)) <= mViewPager.getOffscreenPageLimit();
@Override
protected void onAccountSet(boolean stateWasRecovered) {
+ super.onAccountSet(stateWasRecovered);
if (getAccount() != null) {
OCFile file = getFile();
/// Validate handled file (first image to preview)
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());
+ 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 mStorageManager
+ setFile(file); // reset after getting it fresh from storageManager
getSupportActionBar().setTitle(getFile().getFileName());
//if (!stateWasRecovered) {
initViewPager();
// handled file not in the current Account
finish();
}
-
- } else {
- Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
}
}