androidx.fragment.app.DialogFragment Java Examples
The following examples show how to use
androidx.fragment.app.DialogFragment.
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: CorrectedPreferenceFragment.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public void onDisplayPreferenceDialog(Preference preference) { DialogFragment dialogFragment = null; if (preference instanceof ColorPickerPreference) { dialogFragment = ColorPickerPreferenceDialogFragmentCompat.newInstance(preference.getKey()); } else if (preference instanceof CustomDefaultPreference) { dialogFragment = CustomDefaultPreference.CustomDefaultPreferenceDialogFragmentCompat.newInstance(preference.getKey()); } if (dialogFragment != null) { dialogFragment.setTargetFragment(this, 0); dialogFragment.show(getFragmentManager(), "android.support.v7.preference.PreferenceFragment.DIALOG"); } else { super.onDisplayPreferenceDialog(preference); } }
Example #2
Source File: ArticleTabFragment.java From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 | 6 votes |
private void createGotoDialog() { Bundle args = new Bundle(); args.putInt("page", mPagerAdapter.getCount()); args.putInt("floor", mReplyCount); DialogFragment df = new GotoDialogFragment(); df.setArguments(args); df.setTargetFragment(this, ActivityUtils.REQUEST_CODE_JUMP_PAGE); FragmentManager fm = getActivity().getSupportFragmentManager(); Fragment prev = fm.findFragmentByTag(GOTO_TAG); if (prev != null) { fm.beginTransaction().remove(prev).commit(); } df.show(fm, GOTO_TAG); }
Example #3
Source File: ConfigEditorFragment.java From InviZible with GNU General Public License v3.0 | 6 votes |
@Override public void onStop() { super.onStop(); String input = etConfigEditor.getText().toString(); if (input.isEmpty()) { return; } if (!input.equals(savedText) && getFragmentManager() != null) { DialogFragment dialogFragment = DialogSaveConfigChanges.newInstance(); Bundle bundle = new Bundle(); bundle.putString("moduleName", moduleName); bundle.putString("filePath", filePath); bundle.putString("fileText", input); dialogFragment.setArguments(bundle); dialogFragment.show(getFragmentManager(), "DialogSaveConfigChanges"); } }
Example #4
Source File: SettingsFragment.java From prayer-times-android with Apache License 2.0 | 6 votes |
@SuppressWarnings("RestrictedApi") @Override public void onDisplayPreferenceDialog(Preference preference) { if (preference instanceof NumberPickerPreference) { boolean handled = false; if (getCallbackFragment() instanceof OnPreferenceDisplayDialogCallback) { handled = ((OnPreferenceDisplayDialogCallback) getCallbackFragment()).onPreferenceDisplayDialog(this, preference); } if (!handled && getActivity() instanceof OnPreferenceDisplayDialogCallback) { handled = ((OnPreferenceDisplayDialogCallback) getActivity()).onPreferenceDisplayDialog(this, preference); } if (handled) { return; } if (getFragmentManager().findFragmentByTag("numberpicker") != null) { return; } DialogFragment f = NumberPickerPreference.NumberPickerPreferenceDialogFragmentCompat.newInstance(preference.getKey()); f.setTargetFragment(this, 0); f.show(getFragmentManager(), "numberpicker"); } else super.onDisplayPreferenceDialog(preference); }
Example #5
Source File: ProgressBottomSheet.java From leafpicrevived with GNU General Public License v3.0 | 6 votes |
public ProgressBottomSheet<T> build() { if (sources == null) throw new RuntimeException("You must pass a list of observables"); if (listener == null) Log.w(TAG, "You have not set a listener"); ProgressBottomSheet<T> bottomSheet = new ProgressBottomSheet<>(); bottomSheet.setTitle(title); bottomSheet.setAutoDismiss(autoDismiss); bottomSheet.setShowCancel(showCancel); bottomSheet.setSources(sources); bottomSheet.setListener(listener); bottomSheet.setStyle(DialogFragment.STYLE_NORMAL, R.style.AppTheme); return bottomSheet; }
Example #6
Source File: MainActivityErrorDialog.java From bitmask_android with GNU General Public License v3.0 | 6 votes |
/** * @return a new instance of this DialogFragment. */ public static DialogFragment newInstance(Provider provider, JSONObject errorJson) { MainActivityErrorDialog dialogFragment = new MainActivityErrorDialog(); dialogFragment.provider = provider; try { if (errorJson.has(ERRORS)) { dialogFragment.reasonToFail = errorJson.getString(ERRORS); } else { //default error msg dialogFragment.reasonToFail = dialogFragment.getString(R.string.error_io_exception_user_message); } if (errorJson.has(ERRORID)) { dialogFragment.downloadError = valueOf(errorJson.getString(ERRORID)); } } catch (Exception e) { e.printStackTrace(); dialogFragment.reasonToFail = dialogFragment.getString(R.string.error_io_exception_user_message); } return dialogFragment; }
Example #7
Source File: AppNotificationSettingsActivity.java From an2linuxclient with GNU General Public License v3.0 | 6 votes |
@Override public void onDisplayPreferenceDialog(Preference preference) { String TAG = "NumberPickerPreference"; FragmentManager fm = getFragmentManager(); if (fm.findFragmentByTag(TAG) != null) { return; } if (preference instanceof NumberPickerPreference) { final DialogFragment f = NumberPickerPreferenceDialog.newInstance(preference.getKey()); f.setTargetFragment(this, 0); f.show(fm, TAG); } else { super.onDisplayPreferenceDialog(preference); } }
Example #8
Source File: ScannerListActivity.java From cordova-plugin-foxitpdf with Apache License 2.0 | 6 votes |
private void showScannerList() { FragmentManager fm = getSupportFragmentManager(); DialogFragment fragment = (DialogFragment) fm.findFragmentByTag(SANNER_LIST_TAG); FragmentTransaction transaction = fm.beginTransaction(); if (fragment == null) { fragment = PDFScanManager.createScannerFragment(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { PDFScanManager.unregisterManagerListener(scanManagerListener); ScannerListActivity.this.finish(); } }); } else { transaction.remove(fragment); } transaction.add(fragment, SANNER_LIST_TAG); transaction.commitAllowingStateLoss(); PDFScanManager.registerManagerListener(scanManagerListener); }
Example #9
Source File: MainActivityErrorDialog.java From bitmask_android with GNU General Public License v3.0 | 5 votes |
/** * @return a new instance of this DialogFragment. */ public static DialogFragment newInstance(Provider provider, String reasonToFail, EIP.EIPErrors error) { MainActivityErrorDialog dialogFragment = new MainActivityErrorDialog(); dialogFragment.reasonToFail = reasonToFail; dialogFragment.provider = provider; dialogFragment.downloadError = error; return dialogFragment; }
Example #10
Source File: ViewUtils.java From SmartPack-Kernel-Manager with GNU General Public License v3.0 | 5 votes |
public static void showDialog(FragmentManager manager, DialogFragment fragment) { FragmentTransaction ft = manager.beginTransaction(); Fragment prev = manager.findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); fragment.show(ft, "dialog"); }
Example #11
Source File: PrivacyPolicyFragment.java From mimi-reader with Apache License 2.0 | 5 votes |
/** * Builds and displays a licenses fragment for you. 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 = PrivacyPolicyFragment.newInstance(); newFragment.show(ft, FRAGMENT_TAG); }
Example #12
Source File: ListPreference.java From MaterialPreference with Apache License 2.0 | 5 votes |
@NonNull @Override protected DialogFragment onCreateDialogFragment(String key) { final ListPreferenceDialogFragment fragment = new ListPreferenceDialogFragment(); final Bundle b = new Bundle(1); b.putString(PreferenceDialogFragment.ARG_KEY, key); fragment.setArguments(b); return fragment; }
Example #13
Source File: EditTextPreference.java From MaterialPreference with Apache License 2.0 | 5 votes |
@NonNull @Override protected DialogFragment onCreateDialogFragment(String key) { final EditTextPreferenceDialogFragment fragment = new EditTextPreferenceDialogFragment(); final Bundle b = new Bundle(1); b.putString(PreferenceDialogFragment.ARG_KEY, key); fragment.setArguments(b); return fragment; }
Example #14
Source File: IconPreviewFragment.java From candybar with Apache License 2.0 | 5 votes |
public static void showIconPreview(@NonNull FragmentManager fm, @NonNull String name, int id) { FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(TAG); if (prev != null) { ft.remove(prev); } try { DialogFragment dialog = IconPreviewFragment.newInstance(name, id); dialog.show(ft, TAG); } catch (IllegalArgumentException | IllegalStateException ignored) { } }
Example #15
Source File: SupportFragmentResourceFinderUnitTest.java From MaterialTapTargetPrompt with Apache License 2.0 | 5 votes |
@Test public void testGetPromptParentView() { final DialogFragment dialogFragment = spy(new DialogFragment()); final ViewGroup parent = mock(ViewGroup.class); final ViewGroup view = mock(ViewGroup.class); final SupportFragmentResourceFinder resourceFinder = new SupportFragmentResourceFinder(dialogFragment); when(dialogFragment.getView()).thenReturn(view); when(view.getParent()).thenReturn(parent); assertEquals(parent, resourceFinder.getPromptParentView()); assertEquals(parent, resourceFinder.getPromptParentView()); }
Example #16
Source File: ReactWithAnyEmojiBottomSheetDialogFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public static DialogFragment createForMessageRecord(@NonNull MessageRecord messageRecord) { DialogFragment fragment = new ReactWithAnyEmojiBottomSheetDialogFragment(); Bundle args = new Bundle(); args.putLong(ARG_MESSAGE_ID, messageRecord.getId()); args.putBoolean(ARG_IS_MMS, messageRecord.isMms()); fragment.setArguments(args); return fragment; }
Example #17
Source File: LicensesFragment.java From candybar 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 #18
Source File: ReactionsBottomSheetDialogFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public static DialogFragment create(long messageId, boolean isMms) { Bundle args = new Bundle(); DialogFragment fragment = new ReactionsBottomSheetDialogFragment(); args.putLong(ARGS_MESSAGE_ID, messageId); args.putBoolean(ARGS_IS_MMS, isMms); fragment.setArguments(args); return fragment; }
Example #19
Source File: ViewUtils.java From SmartFlasher with GNU General Public License v3.0 | 5 votes |
public static void showDialog(FragmentManager manager, DialogFragment fragment) { FragmentTransaction ft = manager.beginTransaction(); Fragment prev = manager.findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); fragment.show(ft, "dialog"); }
Example #20
Source File: ReminderPreferences.java From openScale with GNU General Public License v3.0 | 5 votes |
@Override public void onDisplayPreferenceDialog(Preference preference) { DialogFragment dialogFragment = null; if (preference instanceof TimePreference) { dialogFragment = TimePreferenceDialog.newInstance(preference.getKey()); } if (dialogFragment != null) { dialogFragment.setTargetFragment(this, 0); dialogFragment.show(getParentFragmentManager(), "timePreferenceDialog"); } else { super.onDisplayPreferenceDialog(preference); } }
Example #21
Source File: GDPRDialog.java From GDPRDialog with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewManager = new GDPRViewManager(getArguments(), savedInstanceState); mForceActivityToImplementCallback = getArguments().getBoolean(ARG_PARENT_MUST_IMPLEMENT_CALLBACK); GDPRCustomTexts customTexts = mViewManager.getSetup().getCustomTexts(); if (customTexts.hasTitle() && customTexts.getTitle(getContext()).isEmpty()) { setStyle(DialogFragment.STYLE_NO_TITLE, mViewManager.getSetup().customDialogTheme()); } else { setStyle(DialogFragment.STYLE_NORMAL, mViewManager.getSetup().customDialogTheme()); } }
Example #22
Source File: AwesomeActivity.java From AndroidNavigation with MIT License | 5 votes |
public Window getCurrentWindow() { DialogFragment dialogFragment = getDialogFragment(); if (dialogFragment != null && dialogFragment.isAdded()) { return dialogFragment.getDialog().getWindow(); } else { return getWindow(); } }
Example #23
Source File: ScreenResolver.java From Alligator with MIT License | 5 votes |
@NonNull private DialogFragmentDestination getDestination(@NonNull DialogFragment dialogFragment) { Class<? extends Screen> screenClass = mNavigationFactory.getScreenClass(dialogFragment); if (screenClass == null) { throw new IllegalArgumentException("Failed to get screen class from " + dialogFragment.getClass().getSimpleName()); } Destination destination = mNavigationFactory.getDestination(screenClass); if (!(destination instanceof DialogFragmentDestination)) { throw new IllegalArgumentException("Failed to get destination from " + dialogFragment.getClass().getSimpleName()); } return (DialogFragmentDestination) destination; }
Example #24
Source File: BaseDialogFragment.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { if (this.getActivity() != null && shouldUseDefaultDialogStyle()) { setStyle(DialogFragment.STYLE_NO_TITLE, themeManager.getAttributeForTheme(getDialogStyle()).resourceId); } return super.onCreateDialog(savedInstanceState); }
Example #25
Source File: SupportFragmentResourceFinderUnitTest.java From MaterialTapTargetPrompt with Apache License 2.0 | 5 votes |
@Test public void testGetDrawable() { final int resourceId = 64532; final DialogFragment dialogFragment = spy(new DialogFragment()); final SupportFragmentResourceFinder resourceFinder = new SupportFragmentResourceFinder(dialogFragment); final Drawable resource = mock(Drawable.class); final Resources resources = mock(Resources.class); final Context context = mock(Context.class); when(dialogFragment.getContext()).thenReturn(context); when(dialogFragment.getResources()).thenReturn(resources); when(resources.getDrawable(resourceId)).thenReturn(resource); assertEquals(resource, resourceFinder.getDrawable(resourceId)); }
Example #26
Source File: DialogHelper.java From dialog-helper with Apache License 2.0 | 5 votes |
/** * Obtain the ID of the given dialog. This method assumes that the dialog was shown using * DialogHelper. * @return the ID of the given dialog; null if the dialog has no ID */ public @Nullable String getDialogId(@NonNull DialogFragment dialog) { //noinspection ConstantConditions if (dialog == null) { throw new IllegalArgumentException("DialogFragment mustn't be null"); } if (dialog.getArguments() == null || !dialog.getArguments().containsKey(ARGUMENT_DIALOG_ID)) { return null; } else { return dialog.getArguments().getString(ARGUMENT_DIALOG_ID); } }
Example #27
Source File: MainActivity.java From android-versioninfo with Apache License 2.0 | 5 votes |
public void showVersionInfoFragment(final View view) { DialogFragment fragment = VersionInfoDialogFragment.newInstance( getString(R.string.app_name), BuildConfig.VERSION_NAME, "Sascha Peilicke", R.mipmap.ic_launcher); getSupportFragmentManager() .beginTransaction() .replace(R.id.container, fragment) .commit(); }
Example #28
Source File: StockPreferenceFragment.java From APDE with GNU General Public License v2.0 | 5 votes |
@Override public void onDisplayPreferenceDialog(Preference preference) { if (preference instanceof CustomListPreference) { DialogFragment fragment = CustomListPreferenceDialogFragmentCompat.newInstance((CustomListPreference) preference); fragment.setTargetFragment(this, 0); fragment.show(getFragmentManager(), "android.support.v7.preference.PreferenceFragment.DIALOG"); } else { super.onDisplayPreferenceDialog(preference); } }
Example #29
Source File: TopFragment.java From InviZible with GNU General Public License v3.0 | 5 votes |
private boolean coreUpdateReady() { if (getActivity() == null) { return false; } String currentDNSCryptVersionStr = new PrefManager(getActivity()).getStrPref("DNSCryptVersion"); String currentTorVersionStr = new PrefManager(getActivity()).getStrPref("TorVersion"); String currentITPDVersionStr = new PrefManager(getActivity()).getStrPref("ITPDVersion"); if (!(currentDNSCryptVersionStr.isEmpty() && currentTorVersionStr.isEmpty() && currentITPDVersionStr.isEmpty())) { int currentDNSCryptVersion = Integer.parseInt(currentDNSCryptVersionStr.replaceAll("\\D+", "")); int currentTorVersion = Integer.parseInt(currentTorVersionStr.replaceAll("\\D+", "")); int currentITPDVersion = Integer.parseInt(currentITPDVersionStr.replaceAll("\\D+", "")); if (((currentDNSCryptVersion < Integer.parseInt(DNSCryptVersion.replaceAll("\\D+", "")) || currentTorVersion < Integer.parseInt(TorVersion.replaceAll("\\D+", "")) || currentITPDVersion < Integer.parseInt(ITPDVersion.replaceAll("\\D+", ""))) && !new PrefManager(getActivity()).getBoolPref("UpdateNotAllowed"))) { if (isAdded()) { DialogFragment updateCore = UpdateModulesDialogFragment.getInstance(); updateCore.show(getParentFragmentManager(), "UpdateModulesDialogFragment"); } return true; } } return false; }
Example #30
Source File: DefaultDialogFragmentConverter.java From Alligator with MIT License | 5 votes |
@Override @NonNull @SuppressWarnings("unchecked") public ScreenT getScreen(@NonNull DialogFragment dialogFragment) { if (dialogFragment.getArguments() == null) { throw new IllegalArgumentException("Fragment has no arguments."); } else if (Serializable.class.isAssignableFrom(mScreenClass)) { return checkNotNull((ScreenT) dialogFragment.getArguments().getSerializable(KEY_SCREEN)); } else if (Parcelable.class.isAssignableFrom(mScreenClass)) { return checkNotNull((ScreenT) dialogFragment.getArguments().getParcelable(KEY_SCREEN)); } else { throw new IllegalArgumentException("Screen " + mScreenClass.getSimpleName() + " should be Serializable or Parcelable."); } }