/** * Creates a new instance of LicensesFragment with an optional Close button. * * @param showCloseButton Whether to show a Close button at the bottom of the dialog. * @return A new licenses fragment. */ public static LicensesFragment newInstance(boolean showCloseButton) { LicensesFragment fragment = new LicensesFragment(); Bundle bundle = new Bundle(); bundle.putBoolean(KEY_SHOW_CLOSE_BUTTON, showCloseButton); fragment.setArguments(bundle); return fragment; }
/** * 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); }