Search in sources :

Example 1 with FragmentManager

use of androidx.fragment.app.FragmentManager in project Timber by naman14.

the class NowPlayingActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nowplaying);
    SharedPreferences prefs = getSharedPreferences(Constants.FRAGMENT_ID, Context.MODE_PRIVATE);
    String fragmentID = prefs.getString(Constants.NOWPLAYING_FRAGMENT_ID, Constants.TIMBER3);
    Fragment fragment = NavigationUtils.getFragmentForNowplayingID(fragmentID);
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) SharedPreferences(android.content.SharedPreferences) Fragment(androidx.fragment.app.Fragment)

Example 2 with FragmentManager

use of androidx.fragment.app.FragmentManager in project android by owncloud.

the class FileActivity method showUntrustedCertDialog.

/**
 * Show untrusted cert dialog
 */
public void showUntrustedCertDialog(RemoteOperationResult result) {
    // Show a dialog with the certificate info
    FragmentManager fm = getSupportFragmentManager();
    SslUntrustedCertDialog dialog = (SslUntrustedCertDialog) fm.findFragmentByTag(DIALOG_UNTRUSTED_CERT);
    if (dialog == null) {
        dialog = SslUntrustedCertDialog.newInstanceForFullSslError((CertificateCombinedException) result.getException());
        FragmentTransaction ft = fm.beginTransaction();
        dialog.show(ft, DIALOG_UNTRUSTED_CERT);
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) SslUntrustedCertDialog(com.owncloud.android.ui.dialog.SslUntrustedCertDialog) CertificateCombinedException(com.owncloud.android.lib.common.network.CertificateCombinedException)

Example 3 with FragmentManager

use of androidx.fragment.app.FragmentManager 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(androidx.fragment.app.FragmentManager) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment) CopyAndUploadContentUrisTask(com.owncloud.android.ui.asynctasks.CopyAndUploadContentUrisTask)

Example 4 with FragmentManager

use of androidx.fragment.app.FragmentManager in project android by owncloud.

the class ReceiveExternalFilesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // streams need to be prepared before super.onCreate() is called
    prepareStreamsToUpload();
    ActivityExtKt.checkPasscodeEnforced(this, this);
    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(savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT));
    }
    // init ui
    setContentView(R.layout.uploader_layout);
    mSortOptionsView = findViewById(R.id.options_layout);
    if (mSortOptionsView != null) {
        mSortOptionsView.setOnSortOptionsListener(this);
        mSortOptionsView.setOnCreateFolderListener(this);
        mSortOptionsView.selectAdditionalView(SortOptionsView.AdditionalView.CREATE_FOLDER);
    }
    mEmptyListMessage = findViewById(R.id.empty_list_view);
    mListView = findViewById(android.R.id.list);
    mListView.setOnItemClickListener(this);
    // 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();
    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
    mLocalBroadcastManager.registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
    // Listen for upload messages
    IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage());
    uploadIntentFilter.addAction(FileUploader.getUploadStartMessage());
    mUploadBroadcastReceiver = new UploadBroadcastReceiver();
    mLocalBroadcastManager.registerReceiver(mUploadBroadcastReceiver, uploadIntentFilter);
    // 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(androidx.fragment.app.FragmentManager) IntentFilter(android.content.IntentFilter) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment)

Example 5 with FragmentManager

use of androidx.fragment.app.FragmentManager in project Douya by DreaminginCodeZH.

the class ScalpelHelperFragment method attachTo.

/**
 * @deprecated Use {@link #attachToActivity(Fragment)} instead.
 */
public static ScalpelHelperFragment attachTo(FragmentActivity activity) {
    FragmentManager fragmentManager = activity.getSupportFragmentManager();
    ScalpelHelperFragment fragment = (ScalpelHelperFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
    if (fragment == null) {
        fragment = new ScalpelHelperFragment();
        fragmentManager.beginTransaction().add(fragment, FRAGMENT_TAG).commit();
    }
    return fragment;
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager)

Aggregations

FragmentManager (androidx.fragment.app.FragmentManager)146 FragmentTransaction (androidx.fragment.app.FragmentTransaction)49 Fragment (androidx.fragment.app.Fragment)38 Bundle (android.os.Bundle)27 Test (org.junit.Test)15 Intent (android.content.Intent)12 FragmentActivity (androidx.fragment.app.FragmentActivity)10 Activity (android.app.Activity)6 View (android.view.View)6 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)5 DialogFragment (androidx.fragment.app.DialogFragment)4 Context (android.content.Context)3 LayoutInflater (android.view.LayoutInflater)3 MenuInflater (android.view.MenuInflater)3 Window (android.view.Window)3 TextView (android.widget.TextView)3 ViewModelProvider (androidx.lifecycle.ViewModelProvider)3 SslUntrustedCertDialog (com.owncloud.android.ui.dialog.SslUntrustedCertDialog)3 ArrayList (java.util.ArrayList)3 IntentFilter (android.content.IntentFilter)2