List of usage examples for android.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
From source file:com.docd.purefm.ui.activities.BrowserPagerActivity.java
@Override protected void onPause() { super.onPause(); final FragmentManager fm = getFragmentManager(); final Fragment f = fm.findFragmentByTag(TAG_DIALOG); if (f != null) { fm.beginTransaction().remove(f).commit(); fm.executePendingTransactions(); }/*from w w w . j a va 2 s . c o m*/ }
From source file:com.jose.castsocialconnector.main.MainActivity.java
private void showConnectWarningFragment() { ConnectWarningFragment menuFragment = new ConnectWarningFragment(); menuFragment.setmMediaRouteSelector(mMediaRouteSelector); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.fragment_container, menuFragment).addToBackStack(""); transaction.commit();/*from w w w. jav a 2 s . com*/ }
From source file:blackman.matt.infinitebrowser.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation drawer interactions. * * @param fragmentId The android:id of this fragment in its activity's layout. * @param drawerLayout The DrawerLayout containing this fragment's UI. *///from w ww .j a v a 2 s . c om public void setUp(int fragmentId, DrawerLayout drawerLayout) { mFragmentContainerView = getActivity().findViewById(fragmentId); mDrawerLayout = drawerLayout; // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) { /** * Handles the drawer being closed. * * @param drawerView The drawer being closed. */ @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (!isAdded()) { return; } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } /** * Handles the drawer being opened. * * @param drawerView The drawer being opened. */ @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!isAdded()) { return; } if (!mUserLearnedDrawer) { // The user manually opened the drawer; store this flag to prevent auto-showing // the navigation drawer automatically in the future. mUserLearnedDrawer = true; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); } setUpListAdapter(); getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } }; mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String boardRoot = "/tech/"; if (view instanceof TextView) { boardRoot = ((TextView) view).getText().toString(); } FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Board newBoard = Board.newInstance(boardRoot); fragmentTransaction.replace(R.id.container, newBoard, boardRoot); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); closeDrawer(); } }); // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!mUserLearnedDrawer && !mFromSavedInstanceState) { mDrawerLayout.openDrawer(mFragmentContainerView); } // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); }
From source file:fr.cph.chicago.core.activity.BusBoundActivity.java
@Override public final void onStart() { super.onStart(); if (mapFragment == null) { final android.app.FragmentManager fm = getFragmentManager(); final GoogleMapOptions options = new GoogleMapOptions(); final CameraPosition camera = new CameraPosition(Util.CHICAGO, 7, 0, 0); options.camera(camera);/*from w w w.j a va2s . c o m*/ mapFragment = MapFragment.newInstance(options); mapFragment.setRetainInstance(true); fm.beginTransaction().replace(R.id.map, mapFragment).commit(); } }
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}.//w ww . ja v a 2s . 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: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();/* www . ja v a 2 s. c o m*/ }
From source file:io.demiseq.jetreader.activities.MainActivity.java
private void GetNewMangas() { NewFragment fragment = new NewFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "NEW"); fragmentTransaction.commit();/*from w ww .j av a 2 s.co m*/ removeSpinner(); setTitle(new_); }
From source file:io.demiseq.jetreader.activities.MainActivity.java
private void GetRecentList() { RecentFragment fragment = new RecentFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "RECENT"); fragmentTransaction.commit();/*from w w w. j a va2 s. com*/ removeSpinner(); setTitle(recent); }
From source file:io.demiseq.jetreader.activities.MainActivity.java
private void GetSubscription() { SubscriptionFragment fragment = new SubscriptionFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "FEEDS"); fragmentTransaction.commit();//from ww w. java2 s . c om removeSpinner(); setTitle(feeds); }
From source file:io.demiseq.jetreader.activities.MainActivity.java
public void GetDownloaded() { DownloadedFragment fragment = new DownloadedFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "DOWNLOADED"); fragmentTransaction.commit();/*from w ww. j a v a2 s. c om*/ removeSpinner(); setTitle(downloaded); }