Example usage for android.support.v4.app FragmentTransaction commitAllowingStateLoss

List of usage examples for android.support.v4.app FragmentTransaction commitAllowingStateLoss

Introduction

In this page you can find the example usage for android.support.v4.app FragmentTransaction commitAllowingStateLoss.

Prototype

public abstract int commitAllowingStateLoss();

Source Link

Document

Like #commit but allows the commit to be executed after an activity's state is saved.

Usage

From source file:com.nbplus.vbroadlauncher.BaseActivity.java

public void showProgressDialog() {
    dismissProgressDialog();/*ww  w . j  a  v a 2 s. com*/
    mProgressDialogFragment = ProgressDialogFragment.newInstance();

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.add(mProgressDialogFragment, "progress_dialog");
    transaction.commitAllowingStateLoss();
    // for java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    //mProgressDialogFragment.show(getSupportFragmentManager(), "progress_dialog");
}

From source file:com.sefford.fraggle.FraggleManager.java

/**
 * Commits the transaction to the Fragment Manager.
 *
 * @param frag        Fragment to add//w  ww  .ja v a  2 s.  c om
 * @param flags       Added flags to the Fragment configuration
 * @param ft          Transaction to add the fragment
 * @param containerId Target containerID
 */
protected void performTransaction(Fragment frag, int flags, FragmentTransaction ft, int containerId) {
    configureAdditionMode(frag, flags, ft, containerId);
    ft.commitAllowingStateLoss();
}

From source file:org.mythdroid.activities.Status.java

private void installFragments() {

    if (statusDoc == null)
        return;/*from   w  w w  .  j  av a2s  .com*/

    if (!embed) {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(android.R.id.content, new StatusFragment());
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.commitAllowingStateLoss();
    } else {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.recorderframe, new StatusRecordersFragment());
        ft.replace(R.id.jobframe, new StatusJobsFragment());
        ft.replace(R.id.scheduledframe, new StatusScheduledFragment());
        ft.replace(R.id.backendframe, new StatusBackendFragment());
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.commitAllowingStateLoss();
    }

}

From source file:com.sentaroh.android.Utilities.Dialog.ProgressSpinDialogFragment.java

public void showDialog(FragmentManager fm, Fragment frag, NotifyEvent ntfy, boolean cancellable) {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "showDialog");
    mTerminateRequired = false;//from   ww w  .  j  av  a  2  s. com
    mNotifyEvent = ntfy;
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(frag, null);
    ft.commitAllowingStateLoss();

    mDialogCancellable = cancellable;
    //       show(fm, APPLICATION_TAG);
}

From source file:com.hippo.nimingban.ui.PostActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
    setContentView(R.layout.activity_post);

    mPostLayout = (PostLayout) findViewById(R.id.fragment_container);

    if (mPostLayout != null) {
        if (savedInstanceState == null) {
            PostFragment postFragment = new PostFragment();
            postFragment.setArguments(createArgs());
            postFragment.setFragmentHost(this);
            postFragment.setCallback(this);
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.add(R.id.fragment_container, postFragment, TAG_FRAGMENT_POST);
            transaction.commitAllowingStateLoss();
        } else {/*from  w  ww.  j av a 2 s  .co m*/
            FragmentManager fragmentManager = getSupportFragmentManager();
            PostFragment postFragment = (PostFragment) fragmentManager.findFragmentByTag(TAG_FRAGMENT_POST);
            if (postFragment != null) {
                postFragment.setFragmentHost(this);
                postFragment.setCallback(this);
            }
            TypeSendFragment typeSendFragment = (TypeSendFragment) fragmentManager
                    .findFragmentByTag(TAG_FRAGMENT_TYPE_SEND);
            if (typeSendFragment != null) {
                typeSendFragment.setFragmentHost(this);
                typeSendFragment.setCallback(this);
            }
        }
    }
}

From source file:com.battlelancer.seriesguide.ui.ConnectTraktCredentialsFragment.java

@Override
public void onTaskFinished(int resultCode) {
    mTask = null;// w  w w .  j  a  va  2  s  . c o  m

    if (resultCode == NetworkResult.OFFLINE) {
        setStatus(true, false, R.string.offline);
        setButtonStates(true, false);
        return;
    }

    if (resultCode == NetworkResult.ERROR) {
        setStatus(true, false, R.string.trakt_error_credentials);
        setButtonStates(true, false);
        return;
    }

    // if we got here, looks like credentials were stored successfully

    // show further options after successful connection
    if (getFragmentManager() != null) {
        ConnectTraktFinishedFragment f = new ConnectTraktFinishedFragment();
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.content_frame, f);
        ft.commitAllowingStateLoss();
    }
}

From source file:org.mariotaku.twidere.activity.SettingsActivity.java

void showFragment(final Fragment fragment) {
    final FragmentManager fm = getSupportFragmentManager();
    final int entry_count = fm.getBackStackEntryCount();
    final FragmentTransaction ft = fm.beginTransaction();
    for (int i = 0; i < entry_count; i++) {
        final int id = fm.getBackStackEntryAt(i).getId();
        ft.remove(fm.findFragmentById(id));
    }// w w w .  j  a  v  a 2s .c o  m
    ft.commitAllowingStateLoss();
    showFragment(fragment, false);
}

From source file:com.sentaroh.android.Utilities.Dialog.MessageDialogFragment.java

public void showDialog(FragmentManager fm, Fragment frag, NotifyEvent ntfy) {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "showDialog");
    terminateRequired = false;//from w  ww  .ja  v a 2  s .  c  o  m
    mNotifyEvent = ntfy;
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(frag, null);
    ft.commitAllowingStateLoss();
    //       show(fm, APPLICATION_TAG);
}

From source file:com.sentaroh.android.Utilities.Dialog.ProgressBarDialogFragment.java

public void showDialog(FragmentManager fm, Fragment frag, NotifyEvent ntfy, boolean cancellable) {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "showDialog");
    mTerminateRequired = false;//w w w  . j  a va 2  s . c o m
    mNotifyEvent = ntfy;

    mDialogCancellable = cancellable;
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(frag, null);
    ft.commitAllowingStateLoss();
    //       show(fm, APPLICATION_TAG);
}

From source file:com.anthony.app.common.widgets.fragmentNavigator.FragmentNavigator.java

/**
 * reset all the fragment and show given position fragment
 *
 * @param position fragment position/*from w  ww. j a va 2  s  . com*/
 * @param allowingStateLoss true if allowing state loss otherwise false
 */
public void resetFragments(int position, boolean allowingStateLoss) {
    this.mCurrentPosition = position;
    FragmentTransaction transaction = mFragmentManager.beginTransaction();
    removeAll(transaction);
    add(position, transaction);
    if (allowingStateLoss) {
        transaction.commitAllowingStateLoss();
    } else {
        transaction.commit();
    }
}