Example usage for android.app FragmentTransaction remove

List of usage examples for android.app FragmentTransaction remove

Introduction

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

Prototype

public abstract FragmentTransaction remove(Fragment fragment);

Source Link

Document

Remove an existing fragment.

Usage

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

/**
 * ??Fragment./*ww  w .ja  v a2  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.ab.util.AbDialogUtil.java

/**
 * ??Fragment./*from  w ww . j a v  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.//  www. ja  va 2  s  .  co 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);
        if (context != null) {
            ft.commit();
        }
    } catch (Exception e) {
        //?Activity??
        e.printStackTrace();
    }
}

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

/**
 * ??Fragment./*from ww w .  j a v a2 s.  com*/
 * 
 * @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:org.aakashlabs.arthashastra.Advanced_Activity.java

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
    ft.remove(fragment);
}

From source file:ca.farrelltonsolar.uicomponents.TabStripAdapter.java

/**
 * Update an existing tab. Make sure to call {@link #notifyTabsChanged} afterwards.
 *//*  w ww.  j a va  2  s  .  com*/
public void updateTab(int titleRes, Class<?> fragmentClass, Bundle args, int position) {
    if (position >= 0 && position < tabs.size()) {
        // update tab info
        tabs.set(position, new TabInfo(position, fragmentClass, args, titleRes));

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

From source file:ca.farrelltonsolar.uicomponents.TabStripAdapter.java

public void removeTab(Class<?> fragmentClass) {
    int position = 0;
    for (TabInfo ti : tabs) {
        if (ti.mClass.equals(fragmentClass)) {
            tabs.remove(position);//  ww  w  . j a v  a  2  s  . c o  m
            break;
        }
        position++;
    }
    String tag = makeFragmentName(viewPager.getId(), getItemId(position));
    Fragment oldFragment = fragmentManager.findFragmentByTag(tag);
    if (oldFragment != null) {
        //        remove it
        destroyItem(null, position, oldFragment);
        finishUpdate(null);
        viewPager.removeView(oldFragment.getView());
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.remove(oldFragment);
        transaction.commitAllowingStateLoss();
        fragmentManager.executePendingTransactions();
    }
}

From source file:com.example.leonid.chatzilla.UserInterface.CustomDrawer.java

private void updateDisplay(int position) {
    //check for active fragment and delete them
    final ActionBarActivity activity = (ActionBarActivity) mContext;
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    if (activity.getFragmentManager().findFragmentByTag("twitter") != null) {
        ft.remove(activity.getFragmentManager().findFragmentByTag("twitter")).commit();
    }/*  ww w.  j  a va2 s  . co m*/
    if (activity.getFragmentManager().findFragmentByTag("twitter") != null) {
        ft.remove(activity.getFragmentManager().findFragmentByTag("twitter"));
    }
    //create the fragment
    /* Fragment fragment = null;
     switch (position) {
    case 0:
        fragment = new SearchTweetsFragment();
        break;
    case 1:
        fragment = new LoginFragment();
        break;
    default:
        break;
     }
     if (fragment != null&& new NetworkCheck(context).isNetworkConnected()) {
    FragmentManager fragmentManager = activity.getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.frame_container, fragment, "twitter").addToBackStack("twitter").commit();
    //closes drawer
    mDrawerLayout.closeDrawer(mDrawerList);
            
     }*/
}

From source file:com.example.leonid.twitterreader.UserInterface.CustomDrawer.java

private void updateDisplay(int position) {
    //check for active fragment and delete them
    final ActionBarActivity activity = (ActionBarActivity) mContext;
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    if (activity.getFragmentManager().findFragmentByTag("twitter") != null) {
        ft.remove(activity.getFragmentManager().findFragmentByTag("twitter")).commit();
    }//from w  ww .j a v a  2  s  .c o m
    if (activity.getFragmentManager().findFragmentByTag("twitter") != null) {
        ft.remove(activity.getFragmentManager().findFragmentByTag("twitter"));
    }
    //create the fragment
    Fragment fragment = null;
    switch (position) {
    case 0:
        fragment = new SearchTweetsFragment();
        break;
    case 1:
        fragment = new LoginFragment();
        break;
    default:
        break;
    }
    if (fragment != null && (boolean) UtilitiesFactory.checkNetwork(mContext).doTask()) {
        UtilitiesFactory.replaceFragment(mContext, fragment, "twitter", true).doTask();
        //closes drawer
        mDrawerLayout.closeDrawer(mDrawerList);

    }
}

From source file:com.example.android.cloudnotes.ui.HomeActivity.java

/**
 * Callback from child fragment//from   w  ww  . j a v  a2  s.c om
 */
public void onNoteDeleted() {
    // remove the NoteEditFragment after a deletion
    FragmentManager fm = getFragmentManager();
    NoteEditFragment edit = (NoteEditFragment) fm.findFragmentByTag(NOTE_EDIT_TAG);
    if (edit != null) {
        FragmentTransaction ft = fm.beginTransaction();
        ft.remove(edit);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commit();
    }
}