Search in sources :

Example 11 with FragmentManager

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();
        }
    });
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction)

Example 12 with FragmentManager

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");
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment) DialogFragment(android.app.DialogFragment)

Example 13 with FragmentManager

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");
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment) DialogFragment(android.app.DialogFragment)

Example 14 with FragmentManager

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);
        }
    });
}
Also used : AccessTokenTracker(com.facebook.AccessTokenTracker) FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) AccessToken(com.facebook.AccessToken)

Example 15 with FragmentManager

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();
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction)

Aggregations

FragmentManager (android.app.FragmentManager)177 FragmentTransaction (android.app.FragmentTransaction)84 Fragment (android.app.Fragment)51 Bundle (android.os.Bundle)22 DocumentInfo (com.android.documentsui.model.DocumentInfo)20 DialogFragment (android.app.DialogFragment)15 RootInfo (com.android.documentsui.model.RootInfo)15 ActionBar (android.support.v7.app.ActionBar)12 Intent (android.content.Intent)11 File (java.io.File)6 MediaRouter (android.media.MediaRouter)5 Uri (android.net.Uri)5 StorageManager (android.os.storage.StorageManager)5 VolumeInfo (android.os.storage.VolumeInfo)5 MenuItem (android.view.MenuItem)5 IOException (java.io.IOException)5 Toolbar (android.support.v7.widget.Toolbar)4 View (android.view.View)4 DialogInterface (android.content.DialogInterface)3 ViewGroup (android.view.ViewGroup)3