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:org.jraf.android.bikey.common.widget.fragmentcycler.FragmentCycler.java

/**
 * @param tabResId Optional, use 0 for no tab.
 *//*from ww w.j a  v a  2  s  . c o m*/
public void add(FragmentActivity activity, Fragment fragment, int tabResId, int titleResId) {
    String tag = getTag(fragment);
    FragmentManager fragmentManager = activity.getSupportFragmentManager();
    Fragment foundFragment = fragmentManager.findFragmentByTag(tag);
    if (foundFragment == null) {
        FragmentTransaction t = fragmentManager.beginTransaction();
        t.add(mContainerResId, fragment, tag);
        t.hide(fragment);
        t.commit();
    } else {
        FragmentTransaction t = fragmentManager.beginTransaction();
        t.hide(foundFragment);
        t.commit();
    }
    mFragmentTags.add(tag);
    View tab = activity.findViewById(tabResId);
    if (tab != null) {
        mTabs.add((Checkable) tab);
        tab.setOnClickListener(mTabOnClickListener);
    }
    mTitles.add(titleResId);
}

From source file:org.chromium.chrome.browser.media.router.ChromeMediaRouterDialogController.java

/**
 * Shows the {@link MediaRouteChooserDialogFragment} dialog if it's not shown yet.
 * @param sourceUrn the URN identifying the media source to filter the devices with.
 */// ww  w.  ja  va2  s  .c  om
@CalledByNative
public void createDialog(String sourceUrn) {
    if (isShowingDialog())
        return;

    MediaSource mediaSource = MediaSource.from(sourceUrn);
    if (mediaSource == null)
        return;

    FragmentActivity currentActivity = (FragmentActivity) ApplicationStatus.getLastTrackedFocusedActivity();
    if (currentActivity == null)
        return;

    FragmentManager fm = currentActivity.getSupportFragmentManager();
    if (fm == null)
        return;

    if (fm.findFragmentByTag(MEDIA_ROUTE_CHOOSER_DIALOG_FRAGMENT) != null)
        return;

    MediaRouteSelector selector = mediaSource.buildRouteSelector();
    mAndroidMediaRouter.addCallback(selector, this);

    MediaRouteDialogFactory factory = new ChromeMediaRouteDialogFactory();
    mChooserDialogFragment = factory.onCreateChooserDialogFragment();
    mChooserDialogFragment.setRouteSelector(selector);
    mChooserDialogFragment.show(fm, MEDIA_ROUTE_CHOOSER_DIALOG_FRAGMENT);
    fm.executePendingTransactions();

    Dialog dialog = mChooserDialogFragment.getDialog();
    if (dialog == null) {
        closeDialog();
        return;
    }

    dialog.setOnDismissListener(this);
}

From source file:com.conferenceengineer.android.iosched.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.
 *///from ww  w . ja  v  a 2 s.  c om
public ImageLoader(FragmentActivity activity) {
    super(newRequestQueue(activity), BitmapCache.getInstance(activity.getSupportFragmentManager()));
    mResources = activity.getResources();
}

From source file:com.pspdfkit.react.PSPDFKitModule.java

@Override
public void onActivityResult(Activity activity, final int requestCode, final int resultCode,
        final Intent data) {
    if (activity instanceof FragmentActivity) {
        // Forward the result to all our fragments.
        FragmentActivity fragmentActivity = (FragmentActivity) activity;
        for (final Fragment fragment : fragmentActivity.getSupportFragmentManager().getFragments()) {
            if (fragment instanceof PdfFragment || fragment instanceof GalleryImagePickerFragment
                    || fragment instanceof CameraImagePickerFragment) {
                // When starting an intent from a fragment its request code is shifted to make it unique,
                // we undo it here manually since react by default eats all activity results.
                int requestIndex = requestCode >> REQUEST_CODE_TO_INDEX;
                if (requestIndex != 0) {
                    // We need to wait until the next frame with delivering the result to the fragment,
                    // otherwise the app will crash since the fragment won't be ready.
                    activityResultHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            fragment.onActivityResult(requestCode & MASKED_REQUEST_CODE_TO_REAL_CODE,
                                    resultCode, data);
                        }//  ww  w. ja v  a2  s .  c  o m
                    });
                }
            }
        }
    }
}

From source file:io.atrac613.AbstractNfcTagFragment.java

/**
 * ???Activity????/*from w w  w. j  av  a 2  s.c om*/
 * @param activity ????
 * @param tag ?
 */
protected void registerFragment(FragmentActivity activity, String tag) {
    this.unRegisterFragment(activity, tag);
    FragmentManager fm = activity.getSupportFragmentManager();
    FragmentTransaction trans = fm.beginTransaction();
    {
        trans.add(this, tag);
    }
    trans.commit();
    fm.executePendingTransactions();
}

From source file:com.money.manager.ex.adapter.CategoryExpandableListAdapter.java

private void closeFragment() {
    FragmentActivity activity = (FragmentActivity) getContext();
    CategoryListFragment fragment = (CategoryListFragment) activity.getSupportFragmentManager()
            .findFragmentByTag(CategoryListActivity.FRAGMENTTAG);
    fragment.setResultAndFinish();//from w w w  . j a v  a  2s .co  m
}

From source file:com.ovrhere.android.careerstack.model.CareersStackOverflowModel.java

/** Initializes asynchronous model. 
 * @param activity The application's activity. */
public CareersStackOverflowModel(FragmentActivity activity) {
    this.mfragManager = activity.getSupportFragmentManager();
    getHeadlessFrag();//  www.  j ava 2s .  c o m
    //prepare the headless fragment in advance.
    RunnableHeadlessFragment runFrag = getHeadlessFrag();
    if (runFrag.getRunnable() != null) { //if there are any runnables
        try {
            currentRequestWrapper = (CareerStackRequestParserWrapper) runFrag.getRunnable();
            //update any running to the current object
            currentRequestWrapper.setFeedbackListener(this);
        } catch (ClassCastException e) {
        }
    }
}

From source file:org.melato.bus.android.activity.PlanFragment.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.time:
    case R.id.timeLabel: {
        TimeFragment timeFragment = new TimeFragment();
        FragmentActivity activity = (FragmentActivity) getActivity();
        timeFragment.show(activity.getSupportFragmentManager(), "timePicker");
    }/*from ww w  .j  a  v a 2  s . co  m*/
        break;
    case R.id.delete_time:
        timeInMinutes = null;
        timeView.setText(null);
        arriveView.setChecked(arriveAt = false);
        break;
    case R.id.delete_from:
        origin = null;
        showParameters();
        break;
    case R.id.delete_to:
        destination = null;
        showParameters();
        break;
    }
}

From source file:de.dev.eth0.rssreader.app.util.html.rewriter.impl.ImageRewriterImpl.java

@Override
public Object rewrite(final String url) {
    Timber.d("Setup Overlay for Image %s", url);
    return new ClickableSpan() {
        @Override//  ww w.j  a  va  2 s .co  m
        public void onClick(View view) {
            if (context instanceof FragmentActivity) {
                FragmentActivity activity = (FragmentActivity) context;
                ImageOverlayDialog dialog = new ImageOverlayDialog();
                Bundle bundle = new Bundle();
                bundle.putString(FeedEntryTable.COLUMN_LINK, url);
                dialog.setArguments(bundle);
                dialog.show(activity.getSupportFragmentManager(), dialog.getClass().getSimpleName());
            }
        }
    };
}

From source file:com.app.blockydemo.ui.fragment.FormulaEditorVariableListFragment.java

public void showFragment(Context context) {
    FragmentActivity activity = (FragmentActivity) context;
    FragmentManager fragmentManager = activity.getSupportFragmentManager();
    FragmentTransaction fragTransaction = fragmentManager.beginTransaction();

    Fragment formulaEditorFragment = fragmentManager
            .findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG);
    fragTransaction.hide(formulaEditorFragment);

    BottomBar.showBottomBar(activity);//from  w  w  w.j  a v  a2  s  .  co  m
    BottomBar.hidePlayButton(activity);

    fragTransaction.show(this);
    fragTransaction.commit();

    if (adapter != null) {
        initializeUserVariableAdapter();
    }
}