Search in sources :

Example 1 with TaskRetainerFragment

use of com.owncloud.android.ui.fragment.TaskRetainerFragment in project android by owncloud.

the class ReceiveExternalFilesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    prepareStreamsToUpload();
    if (savedInstanceState == null) {
        mParents = new Stack<>();
        mAccountSelected = false;
        mAccountSelectionShowing = false;
    } else {
        mParents = (Stack<String>) savedInstanceState.getSerializable(KEY_PARENTS);
        mFile = savedInstanceState.getParcelable(KEY_FILE);
        mAccountSelected = savedInstanceState.getBoolean(KEY_ACCOUNT_SELECTED);
        mAccountSelectionShowing = savedInstanceState.getBoolean(KEY_ACCOUNT_SELECTION_SHOWING);
    }
    super.onCreate(savedInstanceState);
    if (mAccountSelected) {
        setAccount((Account) savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT));
    }
    // Listen for sync messages
    IntentFilter syncIntentFilter = new IntentFilter(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
    syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
    mSyncBroadcastReceiver = new SyncBroadcastReceiver();
    registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
    // Init Fragment without UI to retain AsyncTask across configuration changes
    FragmentManager fm = getSupportFragmentManager();
    TaskRetainerFragment taskRetainerFragment = (TaskRetainerFragment) fm.findFragmentByTag(TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT);
    if (taskRetainerFragment == null) {
        taskRetainerFragment = new TaskRetainerFragment();
        fm.beginTransaction().add(taskRetainerFragment, TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT).commit();
    }
// else, Fragment already created and retained across configuration change
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) IntentFilter(android.content.IntentFilter) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment)

Example 2 with TaskRetainerFragment

use of com.owncloud.android.ui.fragment.TaskRetainerFragment 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 3 with TaskRetainerFragment

use of com.owncloud.android.ui.fragment.TaskRetainerFragment in project android by owncloud.

the class FileDisplayActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log_OC.v(TAG, "onCreate() start");
    // this calls onAccountChanged() when ownCloud Account
    super.onCreate(savedInstanceState);
    /// grant that FileObserverService is watching favorite files
    if (savedInstanceState == null) {
        FileObserverService.initialize(this);
    }
    /// Load of saved instance state
    if (savedInstanceState != null) {
        mWaitingToPreview = (OCFile) savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW);
        mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS);
        mWaitingToSend = (OCFile) savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND);
    } else {
        mWaitingToPreview = null;
        mSyncInProgress = false;
        mWaitingToSend = null;
    }
    /// USER INTERFACE
    // Inflate and set the layout view
    setContentView(R.layout.files);
    // setup toolbar
    setupToolbar();
    // setup drawer
    setupDrawer(R.id.nav_all_files);
    mDualPane = getResources().getBoolean(R.bool.large_land_layout);
    mLeftFragmentContainer = findViewById(R.id.left_fragment_container);
    mRightFragmentContainer = findViewById(R.id.right_fragment_container);
    // Action bar setup
    getSupportActionBar().setHomeButtonEnabled(true);
    // Init Fragment without UI to retain AsyncTask across configuration changes
    FragmentManager fm = getSupportFragmentManager();
    TaskRetainerFragment taskRetainerFragment = (TaskRetainerFragment) fm.findFragmentByTag(TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT);
    if (taskRetainerFragment == null) {
        taskRetainerFragment = new TaskRetainerFragment();
        fm.beginTransaction().add(taskRetainerFragment, TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT).commit();
    }
    // else, Fragment already created and retained across configuration change
    Log_OC.v(TAG, "onCreate() end");
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)3 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)3 IntentFilter (android.content.IntentFilter)1 CopyAndUploadContentUrisTask (com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask)1