Java Code Examples for android.support.v4.app.FragmentTransaction#remove()
The following examples show how to use
android.support.v4.app.FragmentTransaction#remove() .
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: AlipayAutoPayCancelActivity.java From letv with Apache License 2.0 | 6 votes |
private void showAlipayCloseDialog() { FragmentManager fm = getSupportFragmentManager(); if (fm != null) { FragmentTransaction ft = fm.beginTransaction(); this.mAlipayAutoPayDialog = (AlipayAutoPayCloseDialog) fm.findFragmentByTag("showmAlipayPayCloseDialog"); if (this.mAlipayAutoPayDialog == null) { this.mAlipayAutoPayDialog = new AlipayAutoPayCloseDialog(); } else { ft.remove(this.mAlipayAutoPayDialog); } this.mAlipayAutoPayDialog.setIsMobileVipFlag(this.mIsMobileVipFlag); this.mAlipayAutoPayDialog.setAlipayConfirmCallback(this); ft.add(this.mAlipayAutoPayDialog, "showmAlipayPayCloseDialog"); ft.commitAllowingStateLoss(); } }
Example 2
Source File: BaseDialog.java From COCOFramework with Apache License 2.0 | 6 votes |
public static void showForResult(final FragmentManager fm, final DialogFragment d, final int requestCode) { final FragmentTransaction ft = fm.beginTransaction(); final Fragment prev = fm.findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); if (d.getArguments() == null) { d.setArguments(BaseDialog.createArguments(null, null, requestCode)); } else { d.getArguments().putInt(BaseDialog.ARG_REQUEST_CODE, requestCode); } d.show(ft, null); }
Example 3
Source File: MultiPaneActivity.java From MongoExplorer with MIT License | 6 votes |
@Override protected void loadDocumentDetailsPane(int documentIndex) { DocumentDetailFragment fragment = DocumentDetailFragment.newInstance(mSelectedCollectionIndex, documentIndex); FragmentManager fm = getSupportFragmentManager(); boolean alreadyShiftedFrames = fm.getBackStackEntryCount() > 1; if (!alreadyShiftedFrames) shiftAllLeft(mFrame2, mFrame3, mFrame4); Fragment collectionList = fm.findFragmentById(R.id.frame_2); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.frame_4, fragment); if (!alreadyShiftedFrames) { ft.remove(collectionList); ft.addToBackStack("docdetails"); } ft.commit(); }
Example 4
Source File: BottomSheetFragmentDelegate.java From bottomsheet with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void dismissInternal(boolean allowStateLoss) { if (dismissed) { return; } dismissed = true; shownByMe = false; if (bottomSheetLayout != null) { bottomSheetLayout.dismissSheet(); bottomSheetLayout = null; } viewDestroyed = true; if (backStackId >= 0) { fragment.getFragmentManager().popBackStack(backStackId, FragmentManager.POP_BACK_STACK_INCLUSIVE); backStackId = -1; } else { FragmentTransaction ft = fragment.getFragmentManager().beginTransaction(); ft.remove(fragment); if (allowStateLoss) { ft.commitAllowingStateLoss(); } else { ft.commit(); } } }
Example 5
Source File: CreditsFragment.java From wallpaperboard with Apache License 2.0 | 6 votes |
public static void showCreditsDialog(FragmentManager fm, int type) { FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(TAG); if (prev != null) { ft.remove(prev); } ft.add(newInstance(type), TAG) .setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE); try { ft.commit(); } catch (IllegalStateException e) { ft.commitAllowingStateLoss(); } }
Example 6
Source File: WebViewPhoneFragment.java From carstream-android-auto with Apache License 2.0 | 5 votes |
private void hideNativePlayer() { if (isAdded()) { getView().findViewById(R.id.full_screen_view).setVisibility(View.GONE); FragmentManager fragmentManager = getFragmentManager(); Fragment oldFragment = fragmentManager.findFragmentByTag(PLAYER_FRAGMENT_TAG); if (oldFragment != null) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.remove(oldFragment); fragmentTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); fragmentTransaction.commitAllowingStateLoss(); } } webView.requestFocus(); }
Example 7
Source File: BaseActivity.java From timecat with Apache License 2.0 | 5 votes |
protected void removeDialogFragment() { FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); List<Fragment> fragments = fm.getFragments(); if (fragments == null) { return; } for (Fragment fragment : fragments) { if (fragment instanceof DialogFragment) { ft.remove(fragment); } } ft.commitAllowingStateLoss(); }
Example 8
Source File: MapFragment.java From droidkaigi2016 with Apache License 2.0 | 5 votes |
@Override public void onDestroyView() { FragmentManager fm = getChildFragmentManager(); SupportMapFragment map = (SupportMapFragment) fm.findFragmentById(R.id.map); FragmentTransaction ft = fm.beginTransaction(); ft.remove(map); ft.commitAllowingStateLoss(); super.onDestroyView(); }
Example 9
Source File: FixedPagerAdapter.java From NetEasyNews with GNU General Public License v3.0 | 5 votes |
private void removeFragment(ViewGroup container,int index) { String tag = getFragmentTag(container.getId(), index); Fragment fragment = fm.findFragmentByTag(tag); if (fragment == null) return; FragmentTransaction ft = fm.beginTransaction(); ft.remove(fragment); ft.commit(); ft = null; fm.executePendingTransactions(); }
Example 10
Source File: MainActivity.java From ELM327 with Apache License 2.0 | 5 votes |
private void showChooserDialog(DialogFragment dialogFragment) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Fragment prev = getSupportFragmentManager().findFragmentByTag(TAG_DIALOG); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); dialogFragment.show(ft, "dialog"); }
Example 11
Source File: SearchSettingsDialogFragment.java From 4pdaClient-plus with Apache License 2.0 | 5 votes |
public static void showSearchSettingsDialog(FragmentActivity activity, SearchSettings searchSettings) { FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); Fragment prev = activity.getSupportFragmentManager().findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment newFragment = createSettingsFragment(searchSettings); newFragment.show(ft, "dialog"); }
Example 12
Source File: ConflictsResolveDialog.java From Cirrus_depricated with GNU General Public License v2.0 | 5 votes |
public void dismissDialog(AppCompatActivity activity) { Fragment prev = activity.getSupportFragmentManager().findFragmentByTag(getTag()); if (prev != null) { FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); ft.remove(prev); ft.commit(); } }
Example 13
Source File: DeriveKeystorePageFragmentAdapter.java From Upchain-wallet with GNU Affero General Public License v3.0 | 5 votes |
public void setFragments(List<BaseFragment> fragments) { if (this.fragmentList != null) { FragmentTransaction ft = fm.beginTransaction(); for (Fragment f : this.fragmentList) { ft.remove(f); } ft.commit(); ft = null; fm.executePendingTransactions(); } this.fragmentList = fragments; notifyDataSetChanged(); }
Example 14
Source File: StartConversationActivity.java From Conversations with GNU General Public License v3.0 | 5 votes |
@SuppressLint("InflateParams") protected void showJoinConferenceDialog(final String prefilledJid) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Fragment prev = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_DIALOG); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); JoinConferenceDialog joinConferenceFragment = JoinConferenceDialog.newInstance(prefilledJid, mActivatedAccounts); joinConferenceFragment.show(ft, FRAGMENT_TAG_DIALOG); }
Example 15
Source File: LicensesFragment.java From AndroidLicensesPage with Apache License 2.0 | 5 votes |
/** * Builds and displays a licenses fragment with no Close button. Requires * "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml" to be * present. * * @param fm A fragment manager instance used to display this LicensesFragment. */ public static void displayLicensesFragment(FragmentManager fm) { FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment newFragment = LicensesFragment.newInstance(); newFragment.show(ft, FRAGMENT_TAG); }
Example 16
Source File: LicensesFragment.java From AndroidLicensesPage with Apache License 2.0 | 5 votes |
/** * Builds and displays a licenses fragment with or without a Close button. * Requires "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml" * to be present. * * @param fm A fragment manager instance used to display this LicensesFragment. * @param showCloseButton Whether to show a Close button at the bottom of the dialog. */ public static void displayLicensesFragment(FragmentManager fm, boolean showCloseButton) { FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment newFragment = LicensesFragment.newInstance(showCloseButton); newFragment.show(ft, FRAGMENT_TAG); }
Example 17
Source File: ConflictsResolveDialog.java From Cirrus_depricated with GNU General Public License v2.0 | 5 votes |
public void showDialog(AppCompatActivity activity) { Fragment prev = activity.getSupportFragmentManager().findFragmentByTag("dialog"); FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); this.show(ft, "dialog"); }
Example 18
Source File: LicensesFragment.java From candybar-library with Apache License 2.0 | 5 votes |
public static void showLicensesDialog(FragmentManager fm) { FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(TAG); if (prev != null) { ft.remove(prev); } try { DialogFragment dialog = LicensesFragment.newInstance(); dialog.show(ft, TAG); } catch (IllegalArgumentException | IllegalStateException ignored) {} }
Example 19
Source File: MainActivity.java From ui with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //getSupportFragmentManager().beginTransaction().add(R.id.frag_container, firstFragment).commit(); //first find the 3 fragments, if create them as needed. //Remember fragments can survive the restart of an activity on orientation change. FragmentManager fragmentManager = getSupportFragmentManager(); if (savedInstanceState != null) { leftfrag = (FragLeft) fragmentManager.getFragment(savedInstanceState, "LEFT"); midfrag = (FragMid) fragmentManager.getFragment(savedInstanceState,"MIDDLE"); rightfrag = (FragRight) fragmentManager.getFragment(savedInstanceState,"RIGHT"); //since survived, remove them from the fragment manager, so don't double add them. FragmentTransaction remove = fragmentManager.beginTransaction(); remove.remove(leftfrag); remove.remove(midfrag); remove.remove(rightfrag); if (!remove.isEmpty()) { remove.commit(); fragmentManager.executePendingTransactions(); } } else { leftfrag = new FragLeft(); midfrag = new FragMid(); rightfrag = new FragRight(); } viewPager = (ViewPager) findViewById(R.id.pager); if (viewPager != null) { //in portrait mode viewPager.setAdapter(new ThreeFragmentPagerAdapter(fragmentManager)); } else { //in landscape mode fragmentManager.beginTransaction() .add(R.id.frag_left, leftfrag, "LEFT") .add(R.id.frag_mid, midfrag, "MIDDLE") .add(R.id.frag_right, rightfrag, "RIGHT") .commit(); } }
Example 20
Source File: ToDayStateActivity.java From ToDay with MIT License | 4 votes |
/** * Retrieves the time taken to complete the task while creating a new fragment for the next task. * <p> * If there is no final task an exception is thrown and the Flow is completed * * @param v */ @Override public void onNextSelected(View v) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); try { fragment.cancelTimerAndPassData(overTimeFlag); fragment = ToDayStateFragment.newInstance( parentFlow .getChildElements().get( ++currentElementPosition ) ); overTimeFlag = AppConstants.FS_OVERTIME_FALSE; // Resets for next elements incrementStepView(); transaction.setCustomAnimations( android.R.anim.slide_in_left, android.R.anim.slide_out_right) .replace(R.id.flowstate_fragment_container, fragment) .commit(); } catch (IndexOutOfBoundsException e) { /* Index Out of Bounds Exception Thrown When Flow Ends */ if (fragment != null) { flowStateFlag = AppConstants.FINISHED; transaction.remove(fragment); transaction.commit(); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); } } if (flowStateFlag == AppConstants.FINISHED) { goToFinishScreen(); } }