use of android.app.FragmentManager in project coursera-android by aporter.
the class QuoteViewerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i(TAG, getClass().getSimpleName() + ":entered onCreate()");
super.onCreate(savedInstanceState);
// Get the string arrays with the titles and qutoes
mTitleArray = getResources().getStringArray(R.array.Titles);
mQuoteArray = getResources().getStringArray(R.array.Quotes);
setContentView(R.layout.main);
// Get references to the TitleFragment and to the QuotesFragment
mTitleFrameLayout = (FrameLayout) findViewById(R.id.title_fragment_container);
mQuotesFrameLayout = (FrameLayout) findViewById(R.id.quote_fragment_container);
// Get a reference to the FragmentManager
mFragmentManager = getFragmentManager();
// Start a new FragmentTransaction
FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
// Add the TitleFragment to the layout
fragmentTransaction.add(R.id.title_fragment_container, new TitlesFragment());
// Commit the FragmentTransaction
fragmentTransaction.commit();
// Add a OnBackStackChangedListener to reset the layout when the back stack changes
mFragmentManager.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
public void onBackStackChanged() {
setLayout();
}
});
}
use of android.app.FragmentManager in project cardslib by gabrielemariotti.
the class Utils method showAbout.
public static void showAbout(Activity activity) {
FragmentManager fm = activity.getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag("dialog_about_extras");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
new AboutDialog().show(ft, "dialog_about_extras");
}
use of android.app.FragmentManager in project cardslib by gabrielemariotti.
the class IabUtil method showBeer.
public static void showBeer(Activity activity, IabHelper helper) {
FragmentManager fm = activity.getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag("dialog_purchase");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
new PurchaseDialog(helper).show(ft, "dialog_purchase");
}
use of android.app.FragmentManager in project facebook-android-sdk by facebook.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
userSkippedLogin = savedInstanceState.getBoolean(USER_SKIPPED_LOGIN_KEY);
}
callbackManager = CallbackManager.Factory.create();
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
if (isResumed) {
FragmentManager manager = getFragmentManager();
int backStackSize = manager.getBackStackEntryCount();
for (int i = 0; i < backStackSize; i++) {
manager.popBackStack();
}
if (currentAccessToken != null) {
showFragment(SELECTION, false);
} else {
showFragment(SPLASH, false);
}
}
}
};
setContentView(R.layout.main);
FragmentManager fm = getFragmentManager();
SplashFragment splashFragment = (SplashFragment) fm.findFragmentById(R.id.splashFragment);
fragments[SPLASH] = splashFragment;
fragments[SELECTION] = fm.findFragmentById(R.id.selectionFragment);
fragments[SETTINGS] = fm.findFragmentById(R.id.userSettingsFragment);
FragmentTransaction transaction = fm.beginTransaction();
for (int i = 0; i < fragments.length; i++) {
transaction.hide(fragments[i]);
}
transaction.commit();
splashFragment.setSkipLoginCallback(new SplashFragment.SkipLoginCallback() {
@Override
public void onSkipLoginPressed() {
userSkippedLogin = true;
showFragment(SELECTION, false);
}
});
}
use of android.app.FragmentManager in project facebook-android-sdk by facebook.
the class MainActivity method showFragment.
private void showFragment(int fragmentIndex, boolean addToBackStack) {
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
for (int i = 0; i < fragments.length; i++) {
if (i == fragmentIndex) {
transaction.show(fragments[i]);
} else {
transaction.hide(fragments[i]);
}
}
if (addToBackStack) {
transaction.addToBackStack(null);
}
transaction.commit();
}
Aggregations