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.gm.goldencity.activity.LoginBaseActivity.java

private void attachFragments() {
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(R.id.base_container, loginFragment, TAG_LOGIN_FRAGMENT);
    fragmentTransaction.commitAllowingStateLoss();
}

From source file:am.roadpolice.roadpolice.ActionDialogFragment.java

private void showWatcherDialogFragment() {

    DecisionDialogFragment dialog = (DecisionDialogFragment) getFragmentManager()
            .findFragmentByTag("watcher_dialog");
    if (dialog == null) {
        dialog = new DecisionDialogFragment();
        dialog.setCancelable(false);/*from   ww  w .  j  av a2s .  c  o  m*/
    }

    Bundle bundle = new Bundle();
    bundle.putString(EXTRA_PIN, mPin);

    dialog.setArguments(bundle);

    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.add(dialog, "watcher_dialog");
    transaction.commitAllowingStateLoss();
}

From source file:com.jetradar.multibackstack.sample.MainActivity.java

private void replaceFragment(@NonNull Fragment fragment) {
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction tr = fm.beginTransaction();
    tr.replace(R.id.content, fragment);/*from   w  ww .j  a v a2  s . com*/
    tr.commitAllowingStateLoss();
    curFragment = fragment;
}

From source file:com.mediatek.galleryfeature.stereo.segment.background.MainPanel.java

void loadBackgroundThumbPanel(boolean force) {
    if (!force) {
        return;/*from  w  w w .j  av a  2 s  .co  m*/
    }
    BackgroundThumbPanel bgPanel = new BackgroundThumbPanel();
    FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    transaction.replace(R.id.category_panel_container, bgPanel, BACKGROUNDTHUMB_FRAGMENT_TAG);
    transaction.commitAllowingStateLoss();
}

From source file:com.battlelancer.seriesguide.adapters.TabStripAdapter.java

/**
 * Update an existing tab. Make sure to call {@link #notifyTabsChanged} afterwards.
 *//*from  w w w .ja v  a2  s  . c o m*/
public void updateTab(int titleRes, Class<?> fragmentClass, Bundle args, int position) {
    if (position >= 0 && position < mTabs.size()) {
        // update tab info
        mTabs.set(position, new TabInfo(fragmentClass, args, titleRes));

        // find current fragment of tab
        Fragment oldFragment = mFragmentManager
                .findFragmentByTag(makeFragmentName(mViewPager.getId(), getItemId(position)));
        // remove it
        FragmentTransaction transaction = mFragmentManager.beginTransaction();
        transaction.remove(oldFragment);
        transaction.commitAllowingStateLoss();
        mFragmentManager.executePendingTransactions();
    }
}

From source file:com.nuvolect.securesuite.main.CalendarActivity.java

private void startFileManagerFragment() {

    String url = WebUtil.getServerUrl(getApplicationContext()) + CConst.CALENDAR_PAGE;
    WebFragment webFragment = new WebFragment().newInstance(url);
    String fragmentTag = "webFragmentTag";

    android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

    ft.replace(R.id.finder_webview, webFragment, fragmentTag);
    ft.addToBackStack(null);//w  w  w.ja  v a  2s. c o  m
    ft.commitAllowingStateLoss();
}

From source file:com.nuvolect.securesuite.main.FinderActivity.java

private void startFileManagerFragment() {

    String url = WebUtil.getServerUrl(getApplicationContext()) + CConst.ELFINDER_PAGE;
    WebFragment webFragment = new WebFragment().newInstance(url);
    String fragmentTag = "webFragmentTag";

    android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

    ft.replace(R.id.finder_webview, webFragment, fragmentTag);
    ft.addToBackStack(null);//from   w  w w  . j av a2  s.  c o m
    ft.commitAllowingStateLoss();
}

From source file:com.github.fi3te.iliasdownloader.view.Eula.java

@Override
public MaterialDialog onCreateDialog(Bundle savedInstanceState) {
    setCancelable(false);/* w ww  .  j a  v a2s . c  o  m*/

    Activity activity = getActivity();

    PackageInfo versionInfo = getPackageInfo(activity);
    final String eulaKey = EULA_PREFIX + versionInfo.versionCode;
    final SharedPreferences preferences = PreferencesUtil.getPreferences(activity);

    String title = activity.getString(R.string.app_name) + " v" + versionInfo.versionName;

    String message = activity.getString(R.string.eula);

    return new MaterialDialog.Builder(getActivity()).title(title).content(message)
            .positiveText(android.R.string.ok).negativeText(android.R.string.cancel)
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    SharedPreferences.Editor editor = preferences.edit();
                    editor.putBoolean(eulaKey, true);
                    editor.commit();

                    FragmentManager fm = getFragmentManager();
                    Fragment eula = fm.findFragmentByTag(EULA_FFRAGMENT_TAG);
                    FragmentTransaction ft = fm.beginTransaction();
                    ft.remove(eula);
                    ft.commitAllowingStateLoss();
                    fm.executePendingTransactions();
                }
            }).onNegative(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    getActivity().finishAffinity();
                }
            }).cancelable(false).build();
}

From source file:com.fragmentmaster.sample.ReceiveResult.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mResultView = (TextView) view.findViewById(R.id.resultView);
    view.findViewById(R.id.button).setOnClickListener(new OnClickListener() {
        @Override//from   ww w .j  ava  2  s  .c  o m
        public void onClick(View v) {
            startFragmentForResult(NumbersList.class, REQUEST_CODE);
        }
    });
    FragmentManager fragmentManager = getChildFragmentManager();
    if (fragmentManager.findFragmentByTag("TAG_CHILD") == null) {
        FragmentTransaction ft = fragmentManager.beginTransaction();
        ft.add(R.id.childContainer, new Child(), "TAG_CHILD");
        ft.commitAllowingStateLoss();
        fragmentManager.executePendingTransactions();
    }
}

From source file:nick.dev.sina.app.content.FragmentController.java

public void setCurrent(int index) {
    LoggerManager.getLogger(getClass()).funcEnter();
    FragmentManager fragmentManager = mFragmentManager;
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.hide(getCurrent());//  w ww.  j  a v  a 2 s. c  om
    TransactionSafeFragment current = mPages.get(index);
    transaction.show(current);
    transaction.commitAllowingStateLoss();
    mCurrent = current;
}