Search in sources :

Example 6 with VirtualFolderType

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;
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) Serializable(java.io.Serializable) VirtualFolderType(com.owncloud.android.datamodel.VirtualFolderType) SuppressLint(android.annotation.SuppressLint)

Aggregations

VirtualFolderType (com.owncloud.android.datamodel.VirtualFolderType)6 OCFile (com.owncloud.android.datamodel.OCFile)4 SuppressLint (android.annotation.SuppressLint)2 ContentValues (android.content.ContentValues)2 RemoteOperationFailedException (com.owncloud.android.operations.RemoteOperationFailedException)2 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 Point (android.graphics.Point)1 Handler (android.os.Handler)1 User (com.nextcloud.client.account.User)1 ArbitraryDataProvider (com.owncloud.android.datamodel.ArbitraryDataProvider)1 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)1 RemoteOperation (com.owncloud.android.lib.common.operations.RemoteOperation)1 ReadFileRemoteOperation (com.owncloud.android.lib.resources.files.ReadFileRemoteOperation)1 RemoteFile (com.owncloud.android.lib.resources.files.model.RemoteFile)1 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)1 RefreshFolderOperation (com.owncloud.android.operations.RefreshFolderOperation)1 FileDisplayActivity (com.owncloud.android.ui.activity.FileDisplayActivity)1 FolderPickerActivity (com.owncloud.android.ui.activity.FolderPickerActivity)1 SetupEncryptionDialogFragment (com.owncloud.android.ui.dialog.SetupEncryptionDialogFragment)1