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.utils.image.cache.ImageCache.java

/**
 * Find and return an existing ImageCache stored in a {@link RetainFragment}
 * , if not found a new one is created using the supplied params and saved
 * to a {@link RetainFragment}/* www  .j a  va 2  s  .co m*/
 * 
 * @param activity The calling {@link FragmentActivity}
 * @return An existing retained ImageCache object or a new one if one did
 *         not exist
 */
public static final ImageCache findOrCreateCache(final Activity activity) {
    if (null == activity) {
        return null;
    }

    // Search for, or create an instance of the non-UI RetainFragment
    final RetainFragment retainFragment = findOrCreateRetainFragment(activity.getFragmentManager());

    // See if we already have an ImageCache stored in RetainFragment
    ImageCache cache = (ImageCache) retainFragment.getObject();

    // No existing ImageCache, create one and store it in RetainFragment
    if (cache == null) {
        cache = getInstance(activity);
        retainFragment.setObject(cache);
    }
    return cache;
}

From source file:la.xiong.mylibrary.EasyPermissions.java

public static void requestPermissions(final Object object, int dialogType, final int requestCode,
        int positiveButton, int negativeButton, boolean isAppDialog, final String... perms) {

    checkCallingObjectSuitability(object);

    boolean shouldShowRationale = false;
    for (String perm : perms) {
        shouldShowRationale = shouldShowRationale || shouldShowRequestPermissionRationale(object, perm);
    }/*from  w ww .  jav  a 2  s  . co  m*/

    if (shouldShowRationale) {
        Activity activity = getActivity(object);
        if (null == activity) {
            return;
        }
        //appdialog
        if (isAppDialog == true) {
            if (object instanceof PermissionWithDialogCallbacks) {
                ((PermissionWithDialogCallbacks) object).onDialog(requestCode, dialogType,
                        new DialogCallback() {

                            @Override
                            public void onGranted() {
                                executePermissionsRequest(object, perms, requestCode);
                            }
                        });
            }
        } else {
            showRationaleDialogFragment(activity.getFragmentManager(),
                    activity.getString(R.string.title_rationale_dialog), positiveButton, negativeButton,
                    requestCode, perms);
        }

    } else {
        executePermissionsRequest(object, perms, requestCode);
    }
}

From source file:net.zhuoweizhang.scripteval.TabsAdapter.java

public TabsAdapter(Activity activity, ViewPager pager) {
    super(activity.getFragmentManager());
    mActivity = activity;/*from   w w w.  jav a2s .c o  m*/
    mActionBar = activity.getActionBar();
    mViewPager = pager;
    mViewPager.setAdapter(this);
    mViewPager.setOnPageChangeListener(this);
}

From source file:com.first3.viz.utils.TabsAdapter.java

public TabsAdapter(Activity activity, ActionBar actionBar, ViewPager pager) {
    super(activity.getFragmentManager());
    mContext = activity;/*from w  w  w . j a  v  a  2  s  .com*/
    mActionBar = actionBar;
    mViewPager = pager;
    mViewPager.setAdapter(this);
    mViewPager.setOnPageChangeListener(this);
    // try to recommend that android create and not destroy the fragments
    // that aren't on screen.  This is a hack for the Downloads fragment
    // which we communicate with from a service and we need the Activity to
    // exist so we can make ui updates.
    mViewPager.setOffscreenPageLimit(3);
}

From source file:ca.mymenuapp.ui.widgets.SwipeableActionBarTabsAdapter.java

public SwipeableActionBarTabsAdapter(Activity activity, ViewPager pager,
        DelegateOnPageChangeListener delegate) {
    super(activity.getFragmentManager());
    context = activity;//from  w ww. j  ava2  s  . com
    actionBar = activity.getActionBar();
    viewPager = pager;
    viewPager.setAdapter(this);
    delegate.addOnPageChangeListener(this);
}

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

@SuppressLint("InlinedApi")
private void onDetachNative() {
    Activity fa = getActivity();
    fa.getFragmentManager().popBackStack("content", android.app.FragmentManager.POP_BACK_STACK_INCLUSIVE);
}

From source file:org.onepf.opfiab.opfiab_uitest.tests.ui.UnifiedFragmentHelperTest.java

private static Object createFragment(boolean isSupport, Activity activity, Instrumentation instrumentation,
        int color) throws InterruptedException {
    final Object fragment;
    if (isSupport) {
        fragment = SupportTestFragment.getInstance(color);
        final android.support.v4.app.FragmentManager supportFragmentManager = ((FragmentActivity) activity)
                .getSupportFragmentManager();
        supportFragmentManager.beginTransaction()
                .replace(R.id.content, (android.support.v4.app.Fragment) fragment, FRAGMENT_TAG).commit();
        instrumentation.runOnMainSync(new Runnable() {
            @Override//  w w  w. j  a  v  a  2  s.c  o m
            public void run() {
                supportFragmentManager.executePendingTransactions();
            }
        });
    } else {
        fragment = TestFragment.getInstance(color);
        final FragmentManager fragmentManager = activity.getFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.content, (Fragment) fragment, FRAGMENT_TAG).commit();
        instrumentation.runOnMainSync(new Runnable() {
            @Override
            public void run() {
                fragmentManager.executePendingTransactions();
            }
        });
    }
    Thread.sleep(WAIT_INIT);
    return fragment;
}

From source file:org.onepf.opfiab.ActivityIabHelperImpl.java

ActivityIabHelperImpl(@Nullable final FragmentActivity fragmentActivity, @Nullable final Activity activity) {
    super(fragmentActivity == null ? null : fragmentActivity.getSupportFragmentManager(),
            activity == null ? null : activity.getFragmentManager());
    this.activity = activity;
    this.fragmentActivity = fragmentActivity;
}

From source file:com.bulletingroupblast.bulletingroupblast.GroupOverviewFragment.java

/** The click event for the ListView lstGroups, opens a specific group activity
 *
 * @param adView/* w w  w  .  j a  v a2s . c o m*/
 * @param v
 * @param position
 * @param id
 */
private void onOrgItemClick(AdapterView<?> adView, View v, int position, long id) {
    // Move to another activity
    try {
        // Open the group activity that was selected

        // Intent is for switching to a different activity
        /*Intent intent = new Intent(this,
        com.bulletingroupblast.bulletingroupblast.OrganizationActivity.class);
                
        String message = adView.getItemAtPosition(position).toString();
        intent.putExtra(EXTRA_MESSAGE, message);        // Adds the text value to the intent
        startActivity(intent);*/
        Activity myActivity = getActivity();
        FragmentManager myFragMan = myActivity.getFragmentManager();
        Fragment navFrag = myFragMan.findFragmentById(R.id.lstGroupMenu);

        //            myActivity.onNa

    } catch (Exception e) {
        //            Toast.makeText(v.g(), e.getMessage().toString(), Toast.LENGTH_LONG).show(); // Show a message in toast
    }
}

From source file:nz.org.winters.android.custompreference.FloatPreference.java

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

    Activity activity = (Activity) getContext();

    NumberPickerBuilder numberPickerBuilder = new NumberPickerBuilder();
    numberPickerBuilder.setFragmentManager(activity.getFragmentManager());
    numberPickerBuilder.setStyleResId(R.style.BetterPickersDialogFragment_Light);
    numberPickerBuilder.setPlusMinusVisibility(View.GONE);
    numberPickerBuilder.setDecimalVisibility(View.VISIBLE);
    numberPickerBuilder.addNumberPickerDialogHandler(this);
    numberPickerBuilder.setLabelText(getTitle().toString());
    numberPickerBuilder.show();/*from   ww  w. ja  va2s  .com*/
}