Java Code Examples for androidx.fragment.app.fragment#getFragmentManager()
The following examples show how to use
androidx.fragment.app.fragment#getFragmentManager() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
/** * Shows the dialog. Results will be forwarded to the fragment supplied. * The tag can be used to identify the dialog in {@link OnDialogResultListener#onResult} * An optional argument can be used to remove a previously shown dialog with the tag given * prior to showing this one. * * @param fragment the hosting fragment * @param tag the dialogs tag * @param replaceTag removes the dialog with the given tag if specified */ public void show(Fragment fragment, String tag, String replaceTag){ FragmentManager manager = fragment.getFragmentManager(); if (manager != null) { Fragment existing = manager.findFragmentByTag(replaceTag); if (existing != null){ FragmentManager otherManager = existing.getFragmentManager(); if (otherManager != null) { FragmentTransaction ft = otherManager.beginTransaction(); ft.remove(existing); ft.commit(); } } setTargetFragment(fragment, -1); try { super.show(manager, tag); } catch (IllegalStateException ignored) { } } }
Example 2
Source File: SimpleDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
/** * Shows the dialog. Results will be forwarded to the activity supplied. * The tag can be used to identify the dialog in {@link OnDialogResultListener#onResult} * An optional argument can be used to remove a previously shown dialog with the tag given * prior to showing this one. * * @param activity the hosting activity * @param tag the dialogs tag * @param replaceTag removes the dialog with the given tag if specified */ public void show(FragmentActivity activity, String tag, String replaceTag){ FragmentManager manager = activity.getSupportFragmentManager(); Fragment existing = manager.findFragmentByTag(replaceTag); if (existing != null) { FragmentManager otherManager = existing.getFragmentManager(); if (otherManager != null) { FragmentTransaction ft = otherManager.beginTransaction(); ft.remove(existing); ft.commit(); } } try { super.show(manager, tag); } catch (IllegalStateException ignored) { } }
Example 3
Source File: TrainerCursorAdapter.java From TwistyTimer with GNU General Public License v3.0 | 6 votes |
public TrainerCursorAdapter(Context context, Cursor cursor, Fragment listFragment, TrainerScrambler.TrainerSubset subset, String category) { super(context, cursor, listFragment); Log.d("TrainerCursor", "Created trainerCursor " + subset + category); this.mContext = context; this.fragmentManager = listFragment.getFragmentManager(); // Drawables for the cards cardBackground = ThemeUtils.createSquareDrawable( mContext, ThemeUtils.fetchAttrColor(mContext, R.attr.colorItemListBackground), 0, 14, 0); selectedCardBackground = ThemeUtils.createSquareDrawable( mContext, ThemeUtils.fetchAttrColor(mContext, R.attr.colorItemListBackgroundSelected), Color.BLACK, 14, 2); selectedItems = new ArrayList<>(); selectedItems.addAll(TrainerScrambler.fetchSelectedItems(subset, category)); this.currentSubset = subset; this.currentPuzzleCategory = category; }
Example 4
Source File: SimpleDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
/** * Shows the dialog. Results will be forwarded to the fragment supplied. * The tag can be used to identify the dialog in {@link OnDialogResultListener#onResult} * An optional argument can be used to remove a previously shown dialog with the tag given * prior to showing this one. * * @param fragment the hosting fragment * @param tag the dialogs tag * @param replaceTag removes the dialog with the given tag if specified */ public void show(Fragment fragment, String tag, String replaceTag){ FragmentManager manager = fragment.getFragmentManager(); if (manager != null) { Fragment existing = manager.findFragmentByTag(replaceTag); if (existing != null){ FragmentManager otherManager = existing.getFragmentManager(); if (otherManager != null) { FragmentTransaction ft = otherManager.beginTransaction(); ft.remove(existing); ft.commit(); } } setTargetFragment(fragment, -1); try { super.show(manager, tag); } catch (IllegalStateException ignored) { } } }
Example 5
Source File: SimpleDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
/** * Shows the dialog. Results will be forwarded to the activity supplied. * The tag can be used to identify the dialog in {@link OnDialogResultListener#onResult} * An optional argument can be used to remove a previously shown dialog with the tag given * prior to showing this one. * * @param activity the hosting activity * @param tag the dialogs tag * @param replaceTag removes the dialog with the given tag if specified */ public void show(FragmentActivity activity, String tag, String replaceTag){ FragmentManager manager = activity.getSupportFragmentManager(); Fragment existing = manager.findFragmentByTag(replaceTag); if (existing != null) { FragmentManager otherManager = existing.getFragmentManager(); if (otherManager != null) { FragmentTransaction ft = otherManager.beginTransaction(); ft.remove(existing); ft.commit(); } } try { super.show(manager, tag); } catch (IllegalStateException ignored) { } }
Example 6
Source File: MainActivity.java From SkyTube with GNU General Public License v3.0 | 5 votes |
private void putFragment(FragmentManager fragmentManager, Bundle bundle, @NonNull String key, @NonNull Fragment fragment) { if (fragment.getFragmentManager() != fragmentManager) { Logger.e(MainActivity.this, "Error fragment has a different FragmentManager than expected: Fragment=" + fragment + ", manager=" + fragmentManager + ", Fragment.manager=" + fragment.getFragmentManager() + " for key=" + key); } else { fragmentManager.putFragment(bundle, key, fragment); } }
Example 7
Source File: AwesomeFragment.java From AndroidNavigation with MIT License | 4 votes |
@Override public void onFragmentDestroyed(@NonNull FragmentManager fm, @NonNull Fragment f) { if (fm == f.getFragmentManager() && getTargetFragment() == f) { setTargetFragment(f.getTargetFragment(), f.getTargetRequestCode()); } }
Example 8
Source File: AlgCursorAdapter.java From TwistyTimer with GNU General Public License v3.0 | 4 votes |
public AlgCursorAdapter(Context context, Cursor cursor, Fragment listFragment) { super(cursor); this.mContext = context; this.mFragmentManager = listFragment.getFragmentManager(); colorHash = AlgUtils.getColorLetterHashMap(); }
Example 9
Source File: NumberPickerDialogFragment.java From Jockey with Apache License 2.0 | 4 votes |
public Builder(Fragment fragment) { mFragmentManager = fragment.getFragmentManager(); mTargetFragment = fragment; }
Example 10
Source File: DurationPickerDialogFragment.java From Jockey with Apache License 2.0 | 4 votes |
public Builder(Fragment fragment) { mFragmentManager = fragment.getFragmentManager(); mTargetFragment = fragment; }