Search in sources :

Example 91 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class FolderPickerActivity method browseToRoot.

public void browseToRoot() {
    OCFileListFragment listOfFiles = getListOfFilesFragment();
    if (listOfFiles != null) {
        // should never be null, indeed
        OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
        listOfFiles.listDirectory(root);
        setFile(listOfFiles.getCurrentFile());
        updateNavigationElementsInActionBar();
        startSyncFolderOperation(root, false);
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment)

Example 92 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class PreviewAudioFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    Timber.v("onStart");
    OCFile file = getFile();
    if (file != null && file.isDown()) {
        bindMediaService();
    }
    mProgressController.startListeningProgressFor(getFile(), mAccount);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile)

Example 93 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class PreviewImagePagerAdapter method getItem.

public Fragment getItem(int i) {
    OCFile file = mImageFiles.get(i);
    Fragment fragment;
    if (file.isDown()) {
        fragment = PreviewImageFragment.newInstance(file, mAccount, mObsoletePositions.contains(i));
    } else if (mDownloadErrors.contains(i)) {
        fragment = FileDownloadFragment.newInstance(file, mAccount, true);
        ((FileDownloadFragment) fragment).setError(true);
        mDownloadErrors.remove(i);
    } else {
        fragment = FileDownloadFragment.newInstance(file, mAccount, mObsoletePositions.contains(i));
    }
    mObsoletePositions.remove(i);
    return fragment;
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileFragment(com.owncloud.android.ui.fragment.FileFragment) Fragment(androidx.fragment.app.Fragment)

Example 94 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class PreviewImageActivity method onPageSelected.

/**
 * This method will be invoked when a new page becomes selected. Animation is not necessarily
 * complete.
 *
 * @param position Position index of the new selected page
 */
@Override
public void onPageSelected(int position) {
    Timber.d("onPageSelected %s", position);
    if (getOperationsServiceBinder() != null) {
        mSavedPosition = position;
        mHasSavedPosition = true;
        OCFile currentFile = mPreviewImagePagerAdapter.getFileAt(position);
        updateActionBarTitle(currentFile.getFileName());
        if (!mPreviewImagePagerAdapter.pendingErrorAt(position)) {
            getFileOperationsHelper().syncFile(currentFile);
        }
        // Call to reset image zoom to initial state
        ((PreviewImagePagerAdapter) mViewPager.getAdapter()).resetZoom();
    } else {
        // too soon! ; selection of page (first image) was faster than binding of FileOperationsService;
        // wait a bit!
        final int fPosition = position;
        getHandler().post(new Runnable() {

            @Override
            public void run() {
                onPageSelected(fPosition);
            }
        });
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) SuppressLint(android.annotation.SuppressLint)

Example 95 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class PreviewImageActivity method onAccountSet.

@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 (!file.isImage()) {
            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
            // reset after getting it fresh from storageManager
            setFile(file);
            updateActionBarTitle(getFile().getFileName());
            initViewPager();
        } else {
            // handled file not in the current Account
            finish();
        }
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile)

Aggregations

OCFile (com.owncloud.android.datamodel.OCFile)307 File (java.io.File)56 Test (org.junit.Test)44 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)43 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)40 ArrayList (java.util.ArrayList)28 Intent (android.content.Intent)27 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)22 OCUpload (com.owncloud.android.db.OCUpload)20 ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)20 FileFragment (com.owncloud.android.ui.fragment.FileFragment)19 User (com.nextcloud.client.account.User)17 RemoteFile (com.owncloud.android.lib.resources.files.model.RemoteFile)16 Bundle (android.os.Bundle)13 Fragment (androidx.fragment.app.Fragment)12 RemoteFile (com.owncloud.android.lib.resources.files.RemoteFile)12 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)12 Account (android.accounts.Account)11 SuppressLint (android.annotation.SuppressLint)11 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)11