Example usage for android.app FragmentTransaction addToBackStack

List of usage examples for android.app FragmentTransaction addToBackStack

Introduction

In this page you can find the example usage for android.app FragmentTransaction addToBackStack.

Prototype

public abstract FragmentTransaction addToBackStack(@Nullable String name);

Source Link

Document

Add this transaction to the back stack.

Usage

From source file:cn.org.eshow.framwork.util.AbDialogUtil.java

/**
 * ??Fragment./*from ww w. j av  a 2s .c o m*/
 * @param context the context
 */
public static void removeDialog(final Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        //    
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(dialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        ft.commit();
    } catch (Exception e) {
        //?Activity??
        e.printStackTrace();
    }
}

From source file:com.ab.util.AbDialogUtil.java

/**
 * ??Fragment.//from   ww  w  . j  av a 2  s.  c o  m
 * @param context the context
 */
public static void removeDialog(Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        //    
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        ft.commit();
    } catch (Exception e) {
        //?Activity??
        e.printStackTrace();
    }
}

From source file:com.pszh.ablibrary.util.AbDialogUtil.java

/**
 * ??Fragment./*from   w w  w.ja  v  a  2  s.c om*/
 * @param context the context
 */
public static void removeDialog(Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        //    
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        if (context != null) {
            ft.commit();
        }
    } catch (Exception e) {
        //?Activity??
        e.printStackTrace();
    }
}

From source file:com.tony.selene.dialog.AbDialogUtil.java

/**
 * ??Fragment.//  w  w  w  .java 2  s . co  m
 * 
 * @param context
 *            the context
 */
public static void removeDialog(final Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        // 
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(dialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        ft.commit();
    } catch (Exception e) {
        // ?Activity??
        e.printStackTrace();
    }
}

From source file:com.qrcodereader.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getWindowManager().getDefaultDisplay().getSize(screenParametersPoint);
    layout = (RelativeLayout) findViewById(R.id.main_layout);
    if (savedInstanceState == null) {
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.replace(layout.getId(), new FragmentDecoder());
        fragmentTransaction.commit();//from   w w w  .jav  a  2  s .c o m
    }
}

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

public static void add(FragmentManager fm, SettingsLayoutFragment f) {
    boolean hasDialog = fm.findFragmentByTag(TAG_LEAN_BACK_DIALOG_FRAGMENT) != null;
    FragmentTransaction ft = fm.beginTransaction();

    if (hasDialog) {
        ft.setCustomAnimations(ANIMATION_FRAGMENT_ENTER, ANIMATION_FRAGMENT_EXIT, ANIMATION_FRAGMENT_ENTER_POP,
                ANIMATION_FRAGMENT_EXIT_POP);
        ft.addToBackStack(null);
    }/*from   ww w  .j av  a  2s . c o m*/
    ft.replace(android.R.id.content, f, TAG_LEAN_BACK_DIALOG_FRAGMENT).commit();
}

From source file:edu.umich.titusj.tsr.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(edu.umich.titusj.tsr.R.layout.activity_main);
    getWindowManager().getDefaultDisplay().getSize(screenParametersPoint);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    layout = (FrameLayout) findViewById(edu.umich.titusj.tsr.R.id.main_layout);
    if (savedInstanceState == null) {
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.replace(layout.getId(), new Camera2Fragment());
        fragmentTransaction.commit();/*  ww w  . java 2  s.co m*/
    }
}

From source file:org.chromium.chrome.browser.sync.ui.PassphraseActivity.java

private void displayPassphraseDialog() {
    assert ProfileSyncService.get().isBackendInitialized();
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.addToBackStack(null);
    PassphraseDialogFragment.newInstance(null).show(ft, FRAGMENT_PASSPHRASE);
}

From source file:org.chromium.chrome.browser.sync.ui.PassphraseActivity.java

private void displaySpinnerDialog() {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.addToBackStack(null);
    SpinnerDialogFragment dialog = new SpinnerDialogFragment();
    dialog.show(ft, FRAGMENT_SPINNER);/* ww  w  . ja v a 2 s  .co  m*/
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.LevelOneActivity.java

private void setFragment(Fragment fragment, String fragmentTag) {
    Log.d(TAG, "setFragment: " + fragmentTag);
    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.content_frame_level_one, fragment, fragmentTag);
    transaction.addToBackStack(null);
    transaction.commit();/* ww w  .  j  a v  a 2 s  .c  o m*/
}