DialogFragment loadingDialog = createDialog(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(loadingDialog, "loading"); transaction.commitAllowingStateLoss();
if(!isFinishing()) { FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); DummyFragment dummyFragment = DummyFragment.newInstance(); ft.add(R.id.dummy_fragment_layout, dummyFragment); ft.commitAllowingStateLoss(); }
CheckinSuccessDialog dialog = new CheckinSuccessDialog(); //dialog.show(getSupportFragmentManager(), null); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(dialog, null); ft.commitAllowingStateLoss();
@Override public void finishUpdate(ViewGroup container) { if (mCurTransaction != null) { mCurTransaction.commitAllowingStateLoss(); mCurTransaction = null; mFragmentManager.executePendingTransactions(); } }
public static <T> RetainFragment<T> findOrCreate(FragmentManager fm, String tag) { // noinspection unchecked, we know this is the the right type RetainFragment<T> retainFragment = (RetainFragment<T>) fm.findFragmentByTag(tag); if (retainFragment == null || retainFragment.cleared) { retainFragment = new RetainFragment<>(); fm.beginTransaction() .add(retainFragment, tag) .commitAllowingStateLoss(); } return retainFragment; }
List<Fragment> fragments = fragmentManager.getFragments(); if (fragments != null) { FragmentTransaction ft = fragmentManager.beginTransaction(); for (Fragment f : fragments) { //You can perform additional check to remove some (not all) fragments: if (f instanceof AddedByCurrentPagerAdapterFragment) { ft.remove(f); } } ft.commitAllowingStateLoss(); }
@NonNull private SupportRequestManagerFragment getSupportRequestManagerFragment( @NonNull final FragmentManager fm, @Nullable Fragment parentHint, boolean isParentVisible) { SupportRequestManagerFragment current = (SupportRequestManagerFragment) fm.findFragmentByTag(FRAGMENT_TAG); if (current == null) { current = pendingSupportRequestManagerFragments.get(fm); if (current == null) { current = new SupportRequestManagerFragment(); current.setParentFragmentHint(parentHint); if (isParentVisible) { current.getGlideLifecycle().onStart(); } pendingSupportRequestManagerFragments.put(fm, current); fm.beginTransaction().add(current, FRAGMENT_TAG).commitAllowingStateLoss(); handler.obtainMessage(ID_REMOVE_SUPPORT_FRAGMENT_MANAGER, fm).sendToTarget(); } } return current; }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fragmenttest); mFragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.frame_activity_main, new TestFragment()); fragmentTransaction.commitAllowingStateLoss(); } }
@Override protected String doInBackground(String... params) { QuickControlsFragment fragment1 = new QuickControlsFragment(); FragmentManager fragmentManager1 = getSupportFragmentManager(); fragmentManager1.beginTransaction() .replace(R.id.quickcontrols_container, fragment1).commitAllowingStateLoss(); return "Executed"; }
private void onAlbumSelected(Album album) { if (album.isAll() && album.isEmpty()) { mContainer.setVisibility(View.GONE); mEmptyView.setVisibility(View.VISIBLE); } else { mContainer.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); Fragment fragment = MediaSelectionFragment.newInstance(album); getSupportFragmentManager() .beginTransaction() .replace(R.id.container, fragment, MediaSelectionFragment.class.getSimpleName()) .commitAllowingStateLoss(); } }
public void run() { navigationView.getMenu().findItem(R.id.nav_library).setChecked(true); Fragment fragment = new MainFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_container, fragment).commitAllowingStateLoss(); } };
public void clearAndRemove(FragmentManager fm) { data = null; cleared = true; if (fm.isDestroyed()) { return; } fm.beginTransaction() .remove(this) .commitAllowingStateLoss(); } }
public void showProgress() { ProgressDialogFragment f = ProgressDialogFragment.getInstance(); getFragmentManager().beginTransaction().add(f, PROGRESS_DIALOG).commitAllowingStateLoss(); }
public void showProgress() { ProgressDialogFragment f = ProgressDialogFragment.getInstance(); getFragmentManager().beginTransaction().add(f, PROGRESS_DIALOG).commitAllowingStateLoss(); }
@Override public boolean onQueryTextSubmit(final String query) { hideInputManager(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); SearchTabPagerFragment fragment = SearchTabPagerFragment.newInstance(0, query); ft.replace(R.id.search_frame, fragment).commitAllowingStateLoss(); return true; }
public void refreshTopScene() { int index = mSceneTagList.size() - 1; if (index < 0) { return; } String tag = mSceneTagList.get(index); FragmentManager fragmentManager = getSupportFragmentManager(); Fragment fragment = fragmentManager.findFragmentByTag(tag); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.detach(fragment); transaction.attach(fragment); transaction.commitAllowingStateLoss(); onTransactScene(); }
public void dismissProgress() { if (!isResumed()) return; android.support.v4.app.FragmentManager manager = getFragmentManager(); if (manager == null) return; ProgressDialogFragment f = (ProgressDialogFragment) manager.findFragmentByTag(PROGRESS_DIALOG); if (f != null) { getFragmentManager().beginTransaction().remove(f).commitAllowingStateLoss(); } }
public void dismissProgress() { if (!isResumed()) return; android.support.v4.app.FragmentManager manager = getFragmentManager(); if (manager == null) return; ProgressDialogFragment f = (ProgressDialogFragment) manager.findFragmentByTag(PROGRESS_DIALOG); if (f != null) { getFragmentManager().beginTransaction().remove(f).commitAllowingStateLoss(); } }
@Override public void addFragmentWithTag(String tag, RequestManager manager) { SupportRequestManagerFragment fragment = new SupportRequestManagerFragment(); fragment.setRequestManager(manager); controller.get().getSupportFragmentManager().beginTransaction() .add(fragment, RequestManagerRetriever.FRAGMENT_TAG).commitAllowingStateLoss(); controller.get().getSupportFragmentManager().executePendingTransactions(); } }
public SupportRetrieverHarness() { this.parent = new Fragment(); controller.create(); controller.get().getSupportFragmentManager().beginTransaction().add(parent, PARENT_TAG) .commitAllowingStateLoss(); controller.get().getSupportFragmentManager().executePendingTransactions(); controller.start().resume(); }