use of android.support.v4.app.FragmentManager in project facebook-android-sdk by facebook.
the class MainActivity method showFragment.
void showFragment(int fragmentIndex, boolean addToBackStack) {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
if (addToBackStack) {
transaction.addToBackStack(null);
} else {
int backStackSize = fm.getBackStackEntryCount();
for (int i = 0; i < backStackSize; i++) {
fm.popBackStack();
}
}
for (int i = 0; i < fragments.length; i++) {
if (i == fragmentIndex) {
transaction.show(fragments[i]);
} else {
transaction.hide(fragments[i]);
}
}
transaction.commit();
}
use of android.support.v4.app.FragmentManager in project facebook-android-sdk by facebook.
the class MainActivity method onSaveInstanceState.
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(SHOWING_SETTINGS_KEY, isShowingSettings());
FragmentManager manager = getSupportFragmentManager();
manager.putFragment(outState, SettingsFragment.TAG, settingsFragment);
manager.putFragment(outState, ProfileFragment.TAG, profileFragment);
}
use of android.support.v4.app.FragmentManager in project PocketHub by pockethub.
the class MainActivity method switchFragment.
@VisibleForTesting
void switchFragment(Fragment fragment, User organization) {
if (organization != null) {
Bundle args = new Bundle();
args.putParcelable("org", organization);
fragment.setArguments(args);
}
FragmentManager manager = getSupportFragmentManager();
manager.beginTransaction().replace(R.id.container, fragment).commit();
drawerLayout.closeDrawer(GravityCompat.START);
}
use of android.support.v4.app.FragmentManager in project carat by amplab.
the class MainActivity method replaceFragment.
/*
* shows the fragment using a fragment transaction (replaces the FrameLayout
* (a placeholder in the main activity's layout file) with the passed-in fragment)
*
* @param fragment the fragment that should be shown
* @param tag a name for the fragment to be shown in the
* fragment (task) stack
*/
public void replaceFragment(Fragment fragment, String tag, boolean showDrawerIndicator) {
// use a fragment tag, so that later on we can find the currently displayed fragment
final String FRAGMENT_TAG = tag;
// replace the fragment, using a fragment transaction
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.content_frame, fragment, FRAGMENT_TAG).addToBackStack(FRAGMENT_TAG).commit();
mDrawerToggle.setDrawerIndicatorEnabled(showDrawerIndicator);
}
use of android.support.v4.app.FragmentManager in project robolectric by robolectric.
the class ShadowDialogFragmentTest method removeUsingTransaction_shouldDismissTheDialog.
@Test
public void removeUsingTransaction_shouldDismissTheDialog() throws Exception {
dialogFragment.show(fragmentManager, null);
FragmentTransaction t = fragmentManager.beginTransaction();
t.remove(dialogFragment);
t.commit();
Dialog dialog = ShadowDialog.getLatestDialog();
assertFalse(dialog.isShowing());
assertTrue(shadowOf(dialog).hasBeenDismissed());
}
Aggregations