use of com.owncloud.android.datamodel.VirtualFolderType in project android by nextcloud.
the class PreviewImageActivity method initViewPager.
private void initViewPager(User user) {
// virtual folder
final Serializable virtualFolderType = getIntent().getSerializableExtra(EXTRA_VIRTUAL_TYPE);
if (virtualFolderType != null && virtualFolderType != VirtualFolderType.NONE) {
VirtualFolderType type = (VirtualFolderType) virtualFolderType;
mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), type, user, getStorageManager());
} else {
// get parent from path
OCFile parentFolder = getStorageManager().getFileById(getFile().getParentId());
if (parentFolder == null) {
// should not be necessary
parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
}
mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, user, getStorageManager(), MainApp.isOnlyOnDevice(), preferences);
}
mViewPager = findViewById(R.id.fragmentPager);
int position = mHasSavedPosition ? mSavedPosition : mPreviewImagePagerAdapter.getFilePosition(getFile());
position = position >= 0 ? position : 0;
mViewPager.setAdapter(mPreviewImagePagerAdapter);
mViewPager.addOnPageChangeListener(this);
mViewPager.setCurrentItem(position);
if (position == 0 && !getFile().isDown()) {
// this is necessary because mViewPager.setCurrentItem(0) just after setting the
// adapter does not result in a call to #onPageSelected(0)
mRequestWaitingForBinder = true;
}
}
Aggregations