Example usage for android.support.v4.app FragmentActivity getSupportFragmentManager

List of usage examples for android.support.v4.app FragmentActivity getSupportFragmentManager

Introduction

In this page you can find the example usage for android.support.v4.app FragmentActivity getSupportFragmentManager.

Prototype

public FragmentManager getSupportFragmentManager() 

Source Link

Document

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

Usage

From source file:prince.app.sphotos.util.ImageWorker.java

public void addImageCache(FragmentActivity activity, ImageCache.ImageCacheParams cacheParams) {
    mImageCacheParams = cacheParams;// www  .  j av  a2 s.  co m
    mImageCache = ImageCache.getInstance(activity.getSupportFragmentManager(), mImageCacheParams);
    new CacheAsyncTask().execute(MESSAGE_INIT_DISK_CACHE);
}

From source file:com.ovrhere.android.currencyconverter.model.CurrencyExchangeRateAsyncModel.java

/** Initializes asynchronous model. 
 * @param activity The application's activity. */
public CurrencyExchangeRateAsyncModel(FragmentActivity activity) {
    this.mLocalModel = new CurrencyExchangeRateModel(activity);
    this.res = activity.getResources();
    this.currencyCodeList.addAll(Arrays.asList(res.getStringArray(R.array.currConv_rateOrder)));
    mfragManager = activity.getSupportFragmentManager();
    //prepare the headless fragment in advance.
    RunnableHeadlessFragment runFrag = getHeadlessFrag();
    if (runFrag.getRunnable() != null) { //if there are any runnables
        try {// w  w w .j a  va2  s .c  o m
            YahooApiCurrencyRequest req = (YahooApiCurrencyRequest) runFrag.getRunnable();
            //update any running to the current object
            req.setOnRequestEventListener(this);
        } catch (ClassCastException e) {
        }
    }

    this.prefs = PreferenceUtils.getPreferences(activity);
}

From source file:com.peppe130.fireinstaller.core.CustomFileChooser.java

public void show(FragmentActivity context) {

    final String tag = getBuilder().mTag;

    Fragment frag = context.getSupportFragmentManager().findFragmentByTag(tag);

    if (frag != null) {

        ((DialogFragment) frag).dismiss();

        context.getSupportFragmentManager().beginTransaction().remove(frag).commit();
    }//from   w w  w  .  j a v  a2 s.c o  m

    show(context.getSupportFragmentManager(), tag);

}

From source file:com.facebook.login.WebViewLoginMethodHandler.java

@Override
boolean tryAuthorize(final LoginClient.Request request) {
    Bundle parameters = new Bundle();
    if (!Utility.isNullOrEmpty(request.getPermissions())) {
        String scope = TextUtils.join(",", request.getPermissions());
        parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
        addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
    }/*from   ww  w.j a  v  a2  s. c  om*/

    DefaultAudience audience = request.getDefaultAudience();
    parameters.putString(ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());

    AccessToken previousToken = AccessToken.getCurrentAccessToken();
    String previousTokenString = previousToken != null ? previousToken.getToken() : null;
    if (previousTokenString != null && (previousTokenString.equals(loadCookieToken()))) {
        parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousTokenString);
        // Don't log the actual access token, just its presence or absence.
        addLoggingExtra(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_YES);
    } else {
        // The call to clear cookies will create the first instance of CookieSyncManager if
        // necessary
        Utility.clearFacebookCookies(loginClient.getActivity());
        addLoggingExtra(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_NO);
    }

    WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() {
        @Override
        public void onComplete(Bundle values, FacebookException error) {
            onWebDialogComplete(request, values, error);
        }
    };

    e2e = LoginClient.getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    FragmentActivity fragmentActivity = loginClient.getActivity();
    WebDialog.Builder builder = new AuthDialogBuilder(fragmentActivity, request.getApplicationId(), parameters)
            .setE2E(e2e).setIsRerequest(request.isRerequest()).setOnCompleteListener(listener);
    loginDialog = builder.build();

    FacebookDialogFragment dialogFragment = new FacebookDialogFragment();
    dialogFragment.setRetainInstance(true);
    dialogFragment.setDialog(loginDialog);
    dialogFragment.show(fragmentActivity.getSupportFragmentManager(), FacebookDialogFragment.TAG);

    return true;
}

From source file:org.tomasdavid.vehicleroutingproblem.components.OpenFileButton.java

/**
 * {@inheritDoc}//  ww w .jav  a 2 s  .  c  o  m
 */
@Override
public void onClick(View v) {
    FragmentActivity activity = (FragmentActivity) v.getContext();
    NumberPicker numberPicker = (NumberPicker) activity.findViewById(R.id.timeLimitPicker);
    Spinner algSpinner = (Spinner) activity.findViewById(R.id.algorithm_spinner);

    // add setting values to bundle and starts new fragment
    Bundle bundle = new Bundle();
    bundle.putInt(VrpKeys.VRP_TIME_LIMIT.name(), numberPicker.getValue());
    bundle.putString(VrpKeys.VRP_ALGORITHM.name(), activity.getResources()
            .obtainTypedArray(R.array.algorithm_files).getString(algSpinner.getSelectedItemPosition()));
    VrpFileListFragment fragment = new VrpFileListFragment();
    fragment.setArguments(bundle);
    activity.getSupportFragmentManager().beginTransaction().replace(R.id.activity_main, fragment)
            .addToBackStack(null).commit();
}

From source file:com.simplelife.seeds.android.utils.gridview.gridviewutil.ImageWorker.java

/**
 * Adds an {@link ImageCache} to this {@link ImageWorker} to handle disk and memory bitmap
 * caching.//from   w w w. jav  a  2  s . co m
 * @param activity
 * @param diskCacheDirectoryName See
 * {@link ImageCache.ImageCacheParams#ImageCacheParams(Context, String)}.
 */
public void addImageCache(FragmentActivity activity, String diskCacheDirectoryName, String realDate) {
    mImageCacheParams = new ImageCache.ImageCacheParams(activity, diskCacheDirectoryName);
    mImageCache = ImageCache.getInstance(activity.getSupportFragmentManager(), mImageCacheParams, realDate);
    new CacheAsyncTask().execute(MESSAGE_INIT_DISK_CACHE);
}

From source file:org.catrobat.catroid.utils.DownloadUtil.java

public void prepareDownloadAndStartIfPossible(FragmentActivity activity, String url) {
    String programName = getProjectNameFromUrl(url);
    if (programName == null) {
        return;//from  w  w  w  .  ja  v a  2s  . c o  m
    }

    boolean programNameExists = Utils.checkIfProjectExistsOrIsDownloadingIgnoreCase(programName);
    if (programNameExists) {
        Log.v(TAG, "Program name exists - show overwrite dialog");
        OverwriteRenameDialog renameDialog = new OverwriteRenameDialog();

        renameDialog.setContext(activity);
        renameDialog.setProgramName(programName);
        renameDialog.setURL(url);

        renameDialog.show(activity.getSupportFragmentManager(), OverwriteRenameDialog.DIALOG_FRAGMENT_TAG);
    } else {
        startDownload(activity, url, programName);
    }
}

From source file:ro.expectations.expenses.ui.categories.EditCategoryFragment.java

private boolean confirmDiscard(int requestCode) {
    if (!isDirty()) {
        return false;
    }// ww w.  ja  va2s .  com

    FragmentActivity activity = getActivity();
    if (activity != null) {
        ConfirmationDialogFragment confirmationDialogFragment = ConfirmationDialogFragment.newInstance(null,
                getString(R.string.confirm_discard_changes), getString(R.string.button_discard),
                getString(R.string.button_keep_editing), true);
        confirmationDialogFragment.setTargetFragment(EditCategoryFragment.this, requestCode);
        confirmationDialogFragment.show(activity.getSupportFragmentManager(),
                "NavigateUpConfirmationDialogFragment");
        return true;
    }

    return false;
}

From source file:com.github.nitrico.mapviewpager.MapViewPager.java

public void start(@NonNull FragmentActivity activity, @NonNull AbsAdapter mapAdapter, int initialPosition,
        @Nullable Callback callback) {
    this.initialPosition = initialPosition;
    this.callback = callback;
    adapter = mapAdapter;/* w  w w  .j a v  a2 s.  c om*/
    mapFragment = (SupportMapFragment) activity.getSupportFragmentManager().findFragmentById(R.id.map);
    viewPager = (ViewPager) findViewById(R.id.pager);
    setWeights();
    mapFragment.getMapAsync(this);
}

From source file:com.conferenceengineer.android.iosched.ui.TracksAdapter.java

public TracksAdapter(FragmentActivity activity, boolean isDropDown) {
    super(activity, null, 0);
    mActivity = activity;//ww w . j a  v  a 2  s  . c  o  m
    mIsDropDown = isDropDown;

    // Fetch track icon size in pixels.
    int trackIconSize = activity.getResources().getDimensionPixelSize(R.dimen.track_icon_source_size);

    // Cache size is total pixels by 4 bytes (as format is ARGB_8888) by 20 (max icons to hold
    // in the cache) converted to KB.
    int cacheSize = trackIconSize * trackIconSize * 4 * 20 / 1024;

    // Create a BitmapCache to hold the track icons.
    mBitmapCache = BitmapCache.getInstance(activity.getSupportFragmentManager(), UIUtils.TRACK_ICONS_TAG,
            cacheSize);
}