Search in sources :

Example 1 with CopyAndUploadContentUrisTask

use of com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask in project android by owncloud.

the class UriUploader method copyThenUpload.

/**
     *
     * @param sourceUris        Array of content:// URIs to the files to upload
     * @param remotePaths       Array of absolute paths to set to the uploaded files
     */
private void copyThenUpload(Uri[] sourceUris, String[] remotePaths) {
    if (mShowWaitingDialog) {
        mActivity.showLoadingDialog(R.string.wait_for_tmp_copy_from_private_storage);
    }
    CopyAndUploadContentUrisTask copyTask = new CopyAndUploadContentUrisTask(mCopyTmpTaskListener, mActivity);
    FragmentManager fm = mActivity.getSupportFragmentManager();
    // Init Fragment without UI to retain AsyncTask across configuration changes
    TaskRetainerFragment taskRetainerFragment = (TaskRetainerFragment) fm.findFragmentByTag(TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT);
    if (taskRetainerFragment != null) {
        taskRetainerFragment.setTask(copyTask);
    }
    copyTask.execute(CopyAndUploadContentUrisTask.makeParamsToExecute(mAccount, sourceUris, remotePaths, mBehaviour, mActivity.getContentResolver()));
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment) CopyAndUploadContentUrisTask(com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask)

Example 2 with CopyAndUploadContentUrisTask

use of com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask in project android by owncloud.

the class TaskRetainerFragment method setTask.

/**
     * Sets the task to retain across configuration changes
     *
     * @param task  Task to retain
     */
public void setTask(CopyAndUploadContentUrisTask task) {
    if (mTask != null) {
        mTask.setListener(null);
    }
    mTask = task;
    Context context = getContext();
    if (mTask != null && context != null) {
        if (context instanceof ReceiveExternalFilesActivity) {
            task.setListener((CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener) context);
        } else {
            task.setListener(null);
        }
    }
}
Also used : Context(android.content.Context) CopyAndUploadContentUrisTask(com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask) ReceiveExternalFilesActivity(com.owncloud.android.ui.activity.ReceiveExternalFilesActivity)

Aggregations

CopyAndUploadContentUrisTask (com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask)2 Context (android.content.Context)1 FragmentManager (android.support.v4.app.FragmentManager)1 ReceiveExternalFilesActivity (com.owncloud.android.ui.activity.ReceiveExternalFilesActivity)1 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)1