Example usage for android.app FragmentTransaction commitAllowingStateLoss

List of usage examples for android.app FragmentTransaction commitAllowingStateLoss

Introduction

In this page you can find the example usage for android.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.TurnOrder.MainActivity.java

private void changeNavItem(int position, Player p) {
    Fragment fragment = null;/*from  w  w  w  .  j  a  va2  s.  c  om*/
    switch (position + 1) {
    case 1:
        fragment = new FragmentHome();
        setTitleMenu(titlemenue, "Home");

        break;
    case 2:
        fragment = new FragmentAddPlayer();
        setTitleMenu(titlemenue, "Add Player");
        break;
    case 3:
        fragment = new FragmentViewPlayer(p, playerList);
        setTitleMenu(titlemenue, "View Player");
        break;
    case 4:
        fragment = new FragmentPlay(playerList);
        setTitleMenu(titlemenue, "Play");
        break;
    case 5:
        fragment = new FragmentSplash();
        setTitleMenu(titlemenue, "Savage Worlds Licence");
    }

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    fragmentTransaction.replace(R.id.container, fragment);
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commitAllowingStateLoss();
}

From source file:com.javadog.bluetoothproximitylock.test.BluetoothFragmentTest.java

private Fragment addFragment(Fragment fragment) {
    //Add the BT Fragment to the placeholder activity
    FragmentTransaction transaction = activity.getFragmentManager().beginTransaction();
    transaction.add(R.id.placeholder_fragment_layout, fragment, "abc");
    transaction.commitAllowingStateLoss();
    getInstrumentation().waitForIdleSync();

    //Return a reference to the Fragment once it's inflated
    return activity.getFragmentManager().findFragmentByTag("abc");
}

From source file:com.amazon.android.ui.widget.EllipsizedTextView.java

/**
 * Creates the read dialog fragment and adds it to the fragment.
 *///from  www  .ja v  a2  s  . c om
private void showReadDialog() {
    // Show the dialog
    final ReadDialogFragment dialog = new ReadDialogFragment();
    if (mExpandedContentViewProvider == null) {
        dialog.setContentViewProvider(getDefaultExpandedContentProvider(this));
    } else {
        dialog.setContentViewProvider(mExpandedContentViewProvider);
    }

    if (mReadDialogHeight != 0 && mReadDialogWidth != 0) {
        final Bundle args = new Bundle();
        args.putInt(ReadDialogFragment.INTENT_EXTRA_DIALOG_WIDTH, mReadDialogWidth);
        args.putInt(ReadDialogFragment.INTENT_EXTRA_DIALOG_HEIGHT, mReadDialogHeight);

        dialog.setArguments(args);
    }

    // Commit allowing state loss, in case our activity is being destroyed we won't be in an
    // illegal state.
    final FragmentTransaction ft = ((Activity) getContext()).getFragmentManager().beginTransaction();
    ft.disallowAddToBackStack();
    ft.add(dialog, "read text");
    ft.commitAllowingStateLoss();
}

From source file:com.mediatek.miravision.ui.MiraVisionActivity.java

private void show(FragmentManager fm, Fragment fragment, int orientation) {
    setRequestedOrientation(orientation);
    final FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.content_frame, fragment);
    ft.commitAllowingStateLoss();
}

From source file:com.vaporwarecorp.mirror.feature.main.MirrorActivity.java

private void showDialogFragment(final FragmentManager fragmentManager, final DialogFragment dialogFragment,
        final boolean addToBackStack, final String tag) {
    final FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(dialogFragment, tag);
    if (addToBackStack) {
        transaction.addToBackStack(tag);
    }//from   ww w  . j a  v a  2 s.c  o m
    transaction.commitAllowingStateLoss();
}

From source file:es.rgmf.libresportgps.MainActivity.java

@Override
public void onPostExecute() {
    // Dismiss the dialog progress.
    if (mProgressDialog != null) {
        mProgressDialog.dismiss();//  www  .jav  a 2s  .  c  o m
    }

    // Load the track list fragment to refresh and load the new track.
    FragmentTransaction transaction = mFragmentManager.beginTransaction();
    transaction.replace(R.id.container, TrackListFragment.newInstance());
    mFragmentManager.popBackStack();
    transaction.commitAllowingStateLoss();

    // Activate the rotation screen.
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

}

From source file:com.android.mail.ui.TwoPaneController.java

@Override
protected void hideWaitForInitialization() {
    final WaitFragment waitFragment = getWaitFragment();
    if (waitFragment == null) {
        // We aren't showing a wait fragment: nothing to do
        return;//  w w  w .  j  a  v  a 2s .c  o  m
    }
    // Remove the existing wait fragment from the back stack.
    final FragmentTransaction fragmentTransaction = mActivity.getFragmentManager().beginTransaction();
    fragmentTransaction.remove(waitFragment);
    fragmentTransaction.commitAllowingStateLoss();
    super.hideWaitForInitialization();
    if (mViewMode.isWaitingForSync()) {
        // We should come out of wait mode and display the account inbox.
        loadAccountInbox();
    }
}

From source file:com.android.mail.ui.OnePaneController.java

/**
 * Replace the content_pane with the fragment specified here. The tag is specified so that
 * the {@link ActivityController} can look up the fragments through the
 * {@link android.app.FragmentManager}./*from   w w  w.  ja v a 2 s  .c  om*/
 * @param fragment the new fragment to put
 * @param transition the transition to show
 * @param tag a tag for the fragment manager.
 * @param anchor ID of view to replace fragment in
 * @return transaction ID returned when the transition is committed.
 */
private int replaceFragment(Fragment fragment, int transition, String tag, int anchor) {
    final FragmentManager fm = mActivity.getFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();
    fragmentTransaction.setTransition(transition);
    fragmentTransaction.replace(anchor, fragment, tag);
    final int id = fragmentTransaction.commitAllowingStateLoss();
    fm.executePendingTransactions();
    return id;
}

From source file:org.floens.chan.ui.activity.BoardActivity.java

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

    boardFragment = ThreadFragment.newInstance(this);
    threadFragment = ThreadFragment.newInstance(this);

    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.replace(R.id.left_pane, boardFragment);
    ft.replace(R.id.right_pane, threadFragment);
    ft.commitAllowingStateLoss();

    final ActionBar actionBar = getActionBar();
    actionBar.setListNavigationCallbacks(
            new ArrayAdapter<String>(actionBar.getThemedContext(), R.layout.board_select_spinner,
                    android.R.id.text1, ChanApplication.getBoardManager().getSavedKeys()),
            this);

    updatePaneState();/* w  w w .  j av a 2 s .com*/
    updateActionBarState();

    Intent startIntent = getIntent();
    Uri startUri = startIntent.getData();

    if (savedInstanceState != null) {
        threadLoadable.readFromBundle(this, "thread", savedInstanceState);
        startLoadingThread(threadLoadable);

        // Reset page etc.
        Loadable tmp = new Loadable();
        tmp.readFromBundle(this, "board", savedInstanceState);
        loadBoard(tmp.board);
    } else {
        if (startUri != null) {
            handleIntentURI(startUri);
        }

        if (boardLoadable.mode == Loadable.Mode.INVALID) {
            List<String> savedValues = ChanApplication.getBoardManager().getSavedValues();
            if (savedValues.size() > 0) {
                loadBoard(savedValues.get(0));
            }
        }
    }
}

From source file:com.vaporwarecorp.mirror.feature.main.MirrorActivity.java

private void showFragment(final FragmentManager fragmentManager, final Fragment fragment,
        final boolean addToBackStack, final String tag) {
    // hide the full screen container
    hideFullScreenView();// w w  w.  j a va 2 s.  c  o m

    if (fragmentManager.findFragmentByTag(tag) == null) {
        final int viewId = mContentContainer.addBorderView(this);
        updateCurrentPresenterClass(fragment, viewId);

        final FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(viewId, fragment, tag);
        if (addToBackStack) {
            transaction.addToBackStack(tag);
        }
        transaction.commitAllowingStateLoss();
    } else {
        fragmentManager.beginTransaction().detach(fragment).attach(fragment).commitAllowingStateLoss();
    }
}