Search in sources :

Example 16 with OCFile

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

the class GetShareWithUsersAsyncTask method doInBackground.

@Override
protected Pair<RemoteOperation, RemoteOperationResult> doInBackground(Object... params) {
    GetSharesForFileOperation operation = null;
    RemoteOperationResult result = null;
    if (params != null && params.length == 3) {
        OCFile file = (OCFile) params[0];
        Account account = (Account) params[1];
        FileDataStorageManager fileDataStorageManager = (FileDataStorageManager) params[2];
        try {
            // Get shares request
            operation = new GetSharesForFileOperation(file.getRemotePath(), false, false);
            OwnCloudAccount ocAccount = new OwnCloudAccount(account, MainApp.getAppContext());
            OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, MainApp.getAppContext());
            result = operation.execute(client, fileDataStorageManager);
        } catch (Exception e) {
            result = new RemoteOperationResult(e);
            Log_OC.e(TAG, "Exception while getting shares", e);
        }
    } else {
        result = new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR);
    }
    return new Pair(operation, result);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) Account(android.accounts.Account) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) GetSharesForFileOperation(com.owncloud.android.operations.GetSharesForFileOperation) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) OwnCloudClient(com.owncloud.android.lib.common.OwnCloudClient) Pair(android.util.Pair)

Example 17 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) {
    Log_OC.d(TAG, "onPageSelected " + position);
    if (getOperationsServiceBinder() != null) {
        mSavedPosition = position;
        mHasSavedPosition = true;
        OCFile currentFile = mPreviewImagePagerAdapter.getFileAt(position);
        getSupportActionBar().setTitle(currentFile.getFileName());
        setDrawerIndicatorEnabled(false);
        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 18 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) Fragment(android.support.v4.app.Fragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment)

Example 19 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();
    Log_OC.v(TAG, "onStart");
    OCFile file = getFile();
    if (file != null && file.isDown()) {
        bindMediaService();
    }
    mProgressController.startListeningProgressFor(getFile(), mAccount);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile)

Example 20 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);
            getSupportActionBar().setTitle(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)84 File (java.io.File)14 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)9 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)8 Intent (android.content.Intent)7 Account (android.accounts.Account)6 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)6 FileFragment (com.owncloud.android.ui.fragment.FileFragment)5 Vector (java.util.Vector)5 Bundle (android.os.Bundle)4 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)4 RemoteFile (com.owncloud.android.lib.resources.files.RemoteFile)4 SuppressLint (android.annotation.SuppressLint)3 Bitmap (android.graphics.Bitmap)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 ThumbnailsCacheManager (com.owncloud.android.datamodel.ThumbnailsCacheManager)3 TransferProgressController (com.owncloud.android.ui.controller.TransferProgressController)3 SharedPreferences (android.content.SharedPreferences)2