Example usage for android.app Activity getFragmentManager

List of usage examples for android.app Activity getFragmentManager

Introduction

In this page you can find the example usage for android.app Activity getFragmentManager.

Prototype

@Deprecated
public FragmentManager getFragmentManager() 

Source Link

Document

Return the FragmentManager for interacting with fragments associated with this activity.

Usage

From source file:com.google.android.gms.common.GooglePlayServicesUtil.java

public static boolean showErrorDialogFragment(int errorCode, Activity activity, int requestCode,
        OnCancelListener cancelListener) {
    boolean z = false;
    Dialog errorDialog = getErrorDialog(errorCode, activity, requestCode, cancelListener);
    if (errorDialog == null) {
        return z;
    }/*  w w w  .  j av a  2 s.c o  m*/
    try {
        z = activity instanceof FragmentActivity;
    } catch (NoClassDefFoundError e) {
    }
    if (z) {
        SupportErrorDialogFragment.newInstance(errorDialog, cancelListener)
                .show(((FragmentActivity) activity).getSupportFragmentManager(), GMS_ERROR_DIALOG);
    } else if (gr.fu()) {
        ErrorDialogFragment.newInstance(errorDialog, cancelListener).show(activity.getFragmentManager(),
                GMS_ERROR_DIALOG);
    } else {
        throw new RuntimeException("This Activity does not support Fragments.");
    }
    return true;
}

From source file:com.koushikdutta.widgets.ListContentFragmentInternal.java

@SuppressLint("InlinedApi")
void setContentNative(final String breadcrumb) {
    android.app.Fragment f = (android.app.Fragment) mCurrentContent;
    Activity fa = getActivity();
    final android.app.FragmentManager fm = fa.getFragmentManager();

    android.app.FragmentTransaction ft = fm.beginTransaction();
    if (isPaged()) {
        if (listener == null) {
            fm.addOnBackStackChangedListener(new android.app.FragmentManager.OnBackStackChangedListener() {
                {//from ww  w. j av a  2  s  .  c o m
                    listener = this;
                }

                @Override
                public void onBackStackChanged() {
                    android.app.Fragment f = (android.app.Fragment) getFragment();
                    if (f.isDetached() || f.isRemoving()) {
                        fm.removeOnBackStackChangedListener(this);
                        return;
                    }
                    View v = getFragment().getView();
                    if (v == null)
                        return;
                    final View l = v.findViewById(R.id.list_fragment);
                    if (l == null)
                        return;
                    if (fm.getBackStackEntryCount() > 0 && "content"
                            .equals(fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName())) {
                        l.setVisibility(View.GONE);
                    } else {
                        l.setVisibility(View.VISIBLE);
                    }
                }
            });
        }

        fm.popBackStack("content", android.app.FragmentManager.POP_BACK_STACK_INCLUSIVE);
        ft.setBreadCrumbTitle(breadcrumb);
        ft.setBreadCrumbShortTitle(breadcrumb);
        ft.addToBackStack("content");
    }
    ft.replace(getContentId(), f, "content");
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.commit();
}

From source file:org.alfresco.mobile.android.application.manager.ActionManager.java

public static void actionSend(Activity activity, File myFile, ActionManagerListener listener) {
    try {/* w w w .ja  va2s .c o m*/
        String mimeType = MimeTypeManager.getMIMEType(activity, myFile.getName());
        if (ApplicationManager.getSamsungManager(activity) != null
                && ApplicationManager.getSamsungManager(activity).hasPenEnable()
                && (mimeType == null || mimeType.equals("application/octet-stream")) && MimeTypeManager
                        .getExtension(myFile.getName()).equals(SamsungManager.SAMSUNG_NOTE_EXTENSION_SPD)) {
            mimeType = SamsungManager.SAMSUNG_NOTE_MIMETYPE;
        }
        if (DataProtectionManager.getInstance(activity).isEncrypted(myFile.getPath())) {
            WaitingDialogFragment dialog = WaitingDialogFragment.newInstance(R.string.data_protection,
                    R.string.decryption_title, true);
            dialog.show(activity.getFragmentManager(), WaitingDialogFragment.TAG);
            DataProtectionManager.getInstance(activity).decrypt(SessionUtils.getAccount(activity), myFile,
                    DataProtectionManager.ACTION_SEND);
        } else {
            actionSend(activity, myFile);
        }
    } catch (Exception e) {
        MessengerManager.showToast(activity, R.string.error_unable_open_file);
    }
}

From source file:sg.com.utrix.skeleton.app.sample.util.ImageLoader.java

/**
 * Creates an ImageLoader with Bitmap memory cache. No default placeholder image will be shown
 * while the image is being fetched and loaded.
 *//* w w  w.jav a2 s . co  m*/
public ImageLoader(Activity activity) {
    super(newRequestQueue(activity), BitmapCache.getInstance(activity.getFragmentManager()));
    mResources = activity.getResources();
}

From source file:com.github.cpmproto.categorystepfragment.base.GuidedStepListFragment.java

/**
 * Adds the specified GuidedStepListFragment as content of Activity; no backstack entry is added so
 * the activity will be dismissed when BACK key is pressed.  The method is typically called in
 * Activity.onCreate() when savedInstanceState is null.  When savedInstanceState is not null,
 * the Activity is being restored,  do not call addAsRoot() to duplicate the Fragment restored
 * by FragmentManager./*from  w w  w .  ja  v  a 2s  .  c  o m*/
 * {@link #UI_STYLE_ACTIVITY_ROOT} is assigned.
 * <p/>
 * Note: currently fragments added using this method must be created programmatically rather
 * than via XML.
 *
 * @param activity The Activity to be used to insert GuidedStepListFragment.
 * @param fragment The GuidedStepListFragment to be inserted into the fragment stack.
 * @param id       The id of container to add GuidedStepListFragment, can be android.R.id.content.
 * @return The ID returned by the call FragmentTransaction.commit, or -1 there is already
 * GuidedStepListFragment.
 */
public static int addAsRoot(Activity activity, GuidedStepListFragment fragment, int id) {
    // Workaround b/23764120: call getDecorView() to force requestFeature of ActivityTransition.
    activity.getWindow().getDecorView();
    FragmentManager fragmentManager = activity.getFragmentManager();
    if (fragmentManager.findFragmentByTag(TAG_LEAN_BACK_ACTIONS_FRAGMENT) != null) {
        Log.w(TAG, "Fragment is already exists, likely calling "
                + "addAsRoot() when savedInstanceState is not null in Activity.onCreate().");
        return -1;
    }
    FragmentTransaction ft = fragmentManager.beginTransaction();
    fragment.setUiStyle(UI_STYLE_ACTIVITY_ROOT);
    return ft.replace(id, fragment, TAG_LEAN_BACK_ACTIONS_FRAGMENT).commit();
}

From source file:com.appsimobile.appsihomeplugins.dashclock.configuration.AppChooserPreference.java

@Override
protected void onClick() {
    super.onClick();

    AppChooserDialogFragment fragment = AppChooserDialogFragment.newInstance();
    fragment.setPreference(this);

    Activity activity = (Activity) getContext();
    activity.getFragmentManager().beginTransaction().add(fragment, getFragmentTag()).commit();
}

From source file:sg.com.utrix.skeleton.app.sample.util.ImageLoader.java

/**
 * Creates an ImageLoader with Bitmap memory cache and a default placeholder image while the
 * image is being fetched and loaded./*from  www .j a  v  a2  s .com*/
 */
public ImageLoader(Activity activity, int defaultPlaceHolderResId) {
    super(newRequestQueue(activity), BitmapCache.getInstance(activity.getFragmentManager()));
    mResources = activity.getResources();
    mPlaceHolderDrawables = new ArrayList<Drawable>(1);
    mPlaceHolderDrawables
            .add(defaultPlaceHolderResId == -1 ? null : mResources.getDrawable(defaultPlaceHolderResId));
}

From source file:sg.com.utrix.skeleton.app.sample.util.ImageLoader.java

/**
 * Creates an ImageLoader with Bitmap memory cache and a list of default placeholder drawables.
 *//*from  ww w  .ja v a  2 s.  c om*/
public ImageLoader(Activity activity, ArrayList<Drawable> placeHolderDrawables) {
    super(newRequestQueue(activity), BitmapCache.getInstance(activity.getFragmentManager()));
    mResources = activity.getResources();
    mPlaceHolderDrawables = placeHolderDrawables;
}

From source file:android.support.v17.leanback.app.BackgroundManager.java

/**
 * Returns the BackgroundManager associated with the given Activity.
 * <p>/*from   w  ww.  j  a v a2s  .c o m*/
 * The BackgroundManager will be created on-demand for each individual
 * Activity. Subsequent calls will return the same BackgroundManager created
 * for this Activity.
 */
public static BackgroundManager getInstance(Activity activity) {
    if (activity instanceof FragmentActivity) {
        return getSupportInstance((FragmentActivity) activity);
    }
    BackgroundFragment fragment = (BackgroundFragment) activity.getFragmentManager()
            .findFragmentByTag(FRAGMENT_TAG);
    if (fragment != null) {
        BackgroundManager manager = fragment.getBackgroundManager();
        if (manager != null) {
            return manager;
        }
        // manager is null: this is a fragment restored by FragmentManager,
        // fall through to create a BackgroundManager attach to it.
    }
    return new BackgroundManager(activity, false);
}