com.google.android.material.dialog.MaterialAlertDialogBuilder Java Examples
The following examples show how to use
com.google.android.material.dialog.MaterialAlertDialogBuilder.
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: FilesFragment.java From Aria2App with GNU General Public License v3.0 | 6 votes |
@Override public void onDownloadDirectory(@NonNull MultiProfile profile, @NonNull AriaDirectory dir) { if (dirSheet != null) { dirSheet.dismiss(); dirSheet = null; dismissDialog(); } AnalyticsApplication.sendAnalytics(Utils.ACTION_DOWNLOAD_DIRECTORY); if (Prefs.getBoolean(PK.DD_USE_EXTERNAL)) { AlertDialog.Builder builder = new MaterialAlertDialogBuilder(requireContext()); builder.setTitle(R.string.cannotDownloadDirWithExternal) .setMessage(R.string.cannotDownloadDirWithExternal_message) .setPositiveButton(android.R.string.yes, (dialog, which) -> startDownloadInternal(profile, null, dir)) .setNegativeButton(android.R.string.no, null); showDialog(builder); } else { startDownloadInternal(profile, null, dir); } }
Example #2
Source File: YoutubeLinkSpan.java From mimi-reader with Apache License 2.0 | 6 votes |
private void showChoiceDialog(final Context context) { final String url = MimiUtil.https() + "youtube.com/watch?v=" + videoId; final Handler handler = new Handler(Looper.getMainLooper()); handler.post(() -> new MaterialAlertDialogBuilder(context) .setTitle(R.string.youtube_link) .setItems(R.array.youtube_dialog_list, (dialog, which) -> { if (which == 0) { openLink(context); } else { ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); clipboardManager.setPrimaryClip(ClipData.newPlainText("youtube_link", url)); Toast.makeText(context, R.string.link_copied_to_clipboard, Toast.LENGTH_SHORT).show(); } }) .setCancelable(true) .show() .setCanceledOnTouchOutside(true)); }
Example #3
Source File: AskPermission.java From CommonUtils with Apache License 2.0 | 6 votes |
public static void ask(@NonNull final FragmentActivity activity, @NonNull final String permission, @NonNull final Listener listener) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { listener.permissionGranted(permission); return; } if (ContextCompat.checkSelfPermission(activity, permission) == PackageManager.PERMISSION_GRANTED) { listener.permissionGranted(permission); } else { if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) { MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity); listener.askRationale(builder); builder.setPositiveButton(android.R.string.ok, (dialog, which) -> request(activity, permission, listener)); DialogUtils.showDialog(activity, builder); } else { request(activity, permission, listener); } } }
Example #4
Source File: SpoilerSpan.java From mimi-reader with Apache License 2.0 | 6 votes |
@Override public void onClick(View widget) { // hidden = !hidden; // widget.invalidate(); if (widget instanceof TextView) { TextView tv = (TextView) widget; CharSequence text = tv.getText(); if (text instanceof Spanned) { Spanned s = (Spanned) text; int start = s.getSpanStart(this); int end = s.getSpanEnd(this); new MaterialAlertDialogBuilder(widget.getContext()) .setTitle(R.string.spoiler) .setMessage(s.subSequence(start, end).toString()) .setCancelable(true) .show(); } } }
Example #5
Source File: BoardItemListFragment.java From mimi-reader with Apache License 2.0 | 6 votes |
private void showManageBoardsTutorial() { final LayoutInflater inflater = LayoutInflater.from(getActivity()); final MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(getActivity()); final View dialogView = inflater.inflate(R.layout.dialog_manage_boards_tutorial, null, false); final CheckBox dontShow = dialogView.findViewById(R.id.manage_boards_dont_show); dialogBuilder.setTitle(R.string.manage_boards) .setView(dialogView) .setPositiveButton(R.string.ok, (dialog, which) -> { if (getActivity() != null) { final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity()); pref.edit().putBoolean(getString(R.string.show_manage_boards_tutorial), !dontShow.isChecked()).apply(); } }) .show(); }
Example #6
Source File: GalleryAdapter.java From NClientV2 with Apache License 2.0 | 6 votes |
private void optionDialog(ImageView imgView, final int pos){ ArrayAdapter<String>adapter=new ArrayAdapter<>(context,android.R.layout.select_dialog_item); adapter.add(context.getString(R.string.share)); adapter.add(context.getString(R.string.rotate_image)); if(Global.hasStoragePermission(context))adapter.add(context.getString(R.string.save_page)); MaterialAlertDialogBuilder builder=new MaterialAlertDialogBuilder(context); builder.setTitle(R.string.settings).setIcon(R.drawable.ic_share); builder.setAdapter(adapter, (dialog, which) -> { switch (which){ case 0: openSendImageDialog(imgView,pos); break; case 1: rotate(pos); break; case 2: String name=String.format(Locale.US,"%d-%d.jpg",gallery.getId(),pos); Utility.saveImage(imgView.getDrawable(),new File(Global.SCREENFOLDER,name)); break; } }).show(); }
Example #7
Source File: LocalAdapter.java From NClientV2 with Apache License 2.0 | 6 votes |
private void createContextualMenu(final int pos){ LocalGallery gallery=(LocalGallery) filter.get(pos); ArrayAdapter<String>adapter=new ArrayAdapter<>(context,android.R.layout.select_dialog_item); adapter.add(context.getString(R.string.delete_gallery_size_format,sizeForGallery(gallery))); adapter.add(context.getString(R.string.create_zip)); if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT)adapter.add(context.getString(R.string.create_pdf));//api 19 MaterialAlertDialogBuilder builder=new MaterialAlertDialogBuilder(context); builder.setTitle(R.string.settings).setIcon(R.drawable.ic_settings); builder.setAdapter(adapter, (dialog, which) -> { switch (which){ case 0:showDialogDelete(pos);break; case 1:createZIP(pos);break; case 2:showDialogPDF(pos);break; } }).show(); }
Example #8
Source File: ClusterMapContributeEditActivity.java From intra42 with Apache License 2.0 | 6 votes |
public void onClickControllerDeleteRowCol(final boolean finalIsRow, final LocationWrapper wrapper) { if (wrapper == null) return; final MaterialAlertDialogBuilder alert = new MaterialAlertDialogBuilder(this); alert.setTitle(R.string.cluster_map_contribute_dialog_delete_title); if (finalIsRow) alert.setMessage(app.getString(R.string.cluster_map_contribute_dialog_delete_message_row, wrapper.y)); else alert.setMessage(app.getString(R.string.cluster_map_contribute_dialog_delete_message_col, wrapper.x)); alert.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (finalIsRow) deleteRow(wrapper.y); else deleteColumn(wrapper.x); refreshMap(); } }); alert.setNegativeButton(R.string.cancel, null); alert.show(); }
Example #9
Source File: MenuFragment.java From zephyr with MIT License | 6 votes |
@OnClick(R.id.theme_btn) public void onClickThemeButton() { if (getActivity() == null) { return; } Resources resources = getActivity().getResources(); final CharSequence[] themeChoices = { resources.getString(R.string.menu_debug_theme_system), resources.getString(R.string.menu_debug_theme_light), resources.getString(R.string.menu_debug_theme_dark)}; AlertDialog alertDialog = new MaterialAlertDialogBuilder(getActivity()) .setTitle(R.string.menu_debug_theme_title) .setSingleChoiceItems(themeChoices, themeManager.getCurrentThemeSetting(), (dialog, which) -> { themeManager.setCurrentThemeSetting(which); dialog.dismiss(); }).create(); alertDialog.show(); }
Example #10
Source File: ImagePagerFragment.java From Hentoid with Apache License 2.0 | 6 votes |
private void onDeleteBook() { new MaterialAlertDialogBuilder(requireContext(), ThemeHelper.getIdForCurrentTheme(requireContext(), R.style.Theme_Light_Dialog)) .setIcon(R.drawable.ic_warning) .setCancelable(false) .setTitle(R.string.app_name) .setMessage(R.string.viewer_ask_delete_book) .setPositiveButton(android.R.string.yes, (dialog1, which) -> { dialog1.dismiss(); viewModel.deleteBook(); }) .setNegativeButton(android.R.string.no, (dialog12, which) -> dialog12.dismiss()) .create() .show(); }
Example #11
Source File: ShapeThemingDemoFragment.java From material-components-android with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateDemoView( LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) { View view = layoutInflater.inflate( R.layout.cat_shape_theming_container, viewGroup, false /* attachToRoot */); ViewGroup container = view.findViewById(R.id.container); layoutInflater.inflate(R.layout.cat_shape_theming_content, container, true /* attachToRoot */); MaterialButton materialButton = container.findViewById(R.id.material_button); MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(getContext(), getShapeTheme()) .setTitle(R.string.cat_shape_theming_dialog_title) .setMessage(R.string.cat_shape_theming_dialog_message) .setPositiveButton(R.string.cat_shape_theming_dialog_ok, null); materialButton.setOnClickListener(v -> materialAlertDialogBuilder.show()); BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(wrappedContext); bottomSheetDialog.setContentView(R.layout.cat_shape_theming_bottomsheet_content); View bottomSheetInternal = bottomSheetDialog.findViewById(R.id.design_bottom_sheet); BottomSheetBehavior.from(bottomSheetInternal).setPeekHeight(300); MaterialButton button = container.findViewById(R.id.material_button_2); button.setOnClickListener(v -> bottomSheetDialog.show()); return view; }
Example #12
Source File: ClusterMapContributeActivity.java From intra42 with Apache License 2.0 | 6 votes |
/** * Callback method to be invoked when an item in this Recycler has * been clicked. */ @Override public void onItemClicked(final int position, Cluster item) { MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this); String[] str = new String[]{ getString(R.string.cluster_map_contribute_button_edit_metadata), getString(R.string.cluster_map_contribute_button_edit_layout) }; builder.setItems(str, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) openEditMetadataDialog(clusters.get(position)); else if (which == 1) ClusterMapContributeEditActivity.openIt(ClusterMapContributeActivity.this, clusters.get(position)); } }); builder.setTitle(clusters.get(position).name); builder.show(); }
Example #13
Source File: LibraryFragment.java From Hentoid with Apache License 2.0 | 6 votes |
/** * Display the yes/no dialog to make sure the user really wants to delete selected items * * @param items Items to be deleted if the answer is yes */ private void askDeleteItems(@NonNull final List<Content> items) { Context context = getActivity(); if (null == context) return; MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); String title = context.getResources().getQuantityString(R.plurals.ask_delete_multiple, items.size()); builder.setMessage(title) .setPositiveButton(android.R.string.yes, (dialog, which) -> { selectExtension.deselect(); onDeleteBooks(items); }) .setNegativeButton(android.R.string.no, (dialog, which) -> selectExtension.deselect()) .create().show(); }
Example #14
Source File: PreferenceActivity.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
private void showUnblockDialog(@NonNull Context context) { String[] entries = Prefs.getSet(PK.BLOCKED_USERS, new HashSet<>()).toArray(new String[0]); boolean[] checked = new boolean[entries.length]; MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); builder.setTitle(R.string.unblockUser) .setMultiChoiceItems(entries, checked, (dialog, which, isChecked) -> checked[which] = isChecked) .setPositiveButton(R.string.unblock, (dialog, which) -> { for (int i = 0; i < checked.length; i++) { if (checked[i]) BlockedUsers.unblock(entries[i]); } if (Prefs.isSetEmpty(PK.BLOCKED_USERS)) onBackPressed(); }).setNegativeButton(android.R.string.cancel, null); showDialog(builder); }
Example #15
Source File: ImportHelper.java From Hentoid with Apache License 2.0 | 6 votes |
public static void showExistingLibraryDialog( @NonNull final Context context, @Nullable Runnable cancelCallback ) { new MaterialAlertDialogBuilder(context, ThemeHelper.getIdForCurrentTheme(context, R.style.Theme_Light_Dialog)) .setIcon(R.drawable.ic_warning) .setCancelable(false) .setTitle(R.string.app_name) .setMessage(R.string.contents_detected) .setPositiveButton(android.R.string.yes, (dialog1, which) -> { dialog1.dismiss(); runImport(context, null); }) .setNegativeButton(android.R.string.no, (dialog2, which) -> { dialog2.dismiss(); if (cancelCallback != null) cancelCallback.run(); }) .create() .show(); }
Example #16
Source File: MultiRedditListingActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 6 votes |
public void deleteMultiReddit(MultiReddit multiReddit) { new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) .setTitle(R.string.delete) .setMessage(R.string.delete_multi_reddit_dialog_message) .setPositiveButton(R.string.delete, (dialogInterface, i) -> DeleteMultiReddit.deleteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() { @Override public void success() { Toast.makeText(MultiRedditListingActivity.this, R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show(); loadMultiReddits(); } @Override public void failed() { Toast.makeText(MultiRedditListingActivity.this, R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show(); } })) .setNegativeButton(R.string.cancel, null) .show(); }
Example #17
Source File: MainActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 6 votes |
@Override public void onBackPressed() { DrawerLayout drawer = findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { if (mConfirmToExit) { new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) .setTitle(R.string.exit_app) .setPositiveButton(R.string.yes, (dialogInterface, i) -> finish()) .setNegativeButton(R.string.no, null) .show(); } else { super.onBackPressed(); } } }
Example #18
Source File: CustomThemeListingActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 6 votes |
@Override public void delete(String themeName) { new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) .setTitle(R.string.delete_theme) .setMessage(getString(R.string.delete_theme_dialog_message, themeName)) .setPositiveButton(R.string.yes, (dialogInterface, i) -> new DeleteThemeAsyncTask(redditDataRoomDatabase, themeName, (isLightTheme, isDarkTheme, isAmoledTheme) -> { if (isLightTheme) { CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences( CustomThemeWrapper.getIndigo(CustomThemeListingActivity.this), lightThemeSharedPreferences); } if (isDarkTheme) { CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences( CustomThemeWrapper.getIndigoDark(CustomThemeListingActivity.this), darkThemeSharedPreferences); } if (isAmoledTheme) { CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences( CustomThemeWrapper.getIndigoAmoled(CustomThemeListingActivity.this), amoledThemeSharedPreferences); } EventBus.getDefault().post(new RecreateActivityEvent()); }).execute()) .setNegativeButton(R.string.no, null) .show(); }
Example #19
Source File: OngoingGameFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
public void goBack() { if (isVisible() && DialogUtils.hasVisibleDialog(getActivity())) { DialogUtils.dismissDialog(getActivity()); return; } if (getContext() == null) return; MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle(R.string.leaveGame) .setMessage(R.string.leaveGame_confirm) .setPositiveButton(android.R.string.yes, (dialog, which) -> leaveGame()) .setNegativeButton(android.R.string.no, null); DialogUtils.showDialog(getActivity(), builder); }
Example #20
Source File: SubscribedThingListingActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 6 votes |
public void deleteMultiReddit(MultiReddit multiReddit) { new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) .setTitle(R.string.delete) .setMessage(R.string.delete_multi_reddit_dialog_message) .setPositiveButton(R.string.delete, (dialogInterface, i) -> DeleteMultiReddit.deleteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() { @Override public void success() { Toast.makeText(SubscribedThingListingActivity.this, R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show(); loadMultiReddits(); } @Override public void failed() { Toast.makeText(SubscribedThingListingActivity.this, R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show(); } })) .setNegativeButton(R.string.cancel, null) .show(); }
Example #21
Source File: GamesFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
private void askForPassword(@NonNull OnPassword listener) { if (getContext() == null) { listener.onPassword(null); return; } final EditText password = new EditText(getContext()); password.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle(R.string.gamePassword) .setView(password) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(R.string.submit, (dialog, which) -> listener.onPassword(password.getText().toString())); DialogUtils.showDialog(getActivity(), builder); }
Example #22
Source File: ViewPostDetailActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 6 votes |
public void deleteComment(String fullName, int position) { new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) .setTitle(R.string.delete_this_comment) .setMessage(R.string.are_you_sure) .setPositiveButton(R.string.delete, (dialogInterface, i) -> DeleteThing.delete(mOauthRetrofit, fullName, mAccessToken, new DeleteThing.DeleteThingListener() { @Override public void deleteSuccess() { Toast.makeText(ViewPostDetailActivity.this, R.string.delete_post_success, Toast.LENGTH_SHORT).show(); mAdapter.deleteComment(position); } @Override public void deleteFailed() { Toast.makeText(ViewPostDetailActivity.this, R.string.delete_post_failed, Toast.LENGTH_SHORT).show(); } })) .setNegativeButton(R.string.cancel, null) .show(); }
Example #23
Source File: ViewUserDetailActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 6 votes |
public void deleteComment(String fullName) { new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) .setTitle(R.string.delete_this_comment) .setMessage(R.string.are_you_sure) .setPositiveButton(R.string.delete, (dialogInterface, i) -> DeleteThing.delete(mOauthRetrofit, fullName, mAccessToken, new DeleteThing.DeleteThingListener() { @Override public void deleteSuccess() { Toast.makeText(ViewUserDetailActivity.this, R.string.delete_post_success, Toast.LENGTH_SHORT).show(); } @Override public void deleteFailed() { Toast.makeText(ViewUserDetailActivity.this, R.string.delete_post_failed, Toast.LENGTH_SHORT).show(); } })) .setNegativeButton(R.string.cancel, null) .show(); }
Example #24
Source File: ImageBottomSheetFragment.java From Hentoid with Apache License 2.0 | 6 votes |
/** * Handle click on "Delete" action button */ private void onDeleteClick() { new MaterialAlertDialogBuilder(requireContext(), ThemeHelper.getIdForCurrentTheme(requireContext(), R.style.Theme_Light_Dialog)) .setIcon(R.drawable.ic_warning) .setCancelable(false) .setTitle(R.string.app_name) .setMessage(R.string.viewer_ask_delete_page) .setPositiveButton(android.R.string.yes, (dialog1, which) -> { dialog1.dismiss(); viewModel.deletePage(imageIndex); }) .setNegativeButton(android.R.string.no, (dialog12, which) -> dialog12.dismiss()) .create() .show(); }
Example #25
Source File: GoToPageDialogFragment.java From Hentoid with Apache License 2.0 | 6 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { EditText input = new EditText(getContext()); input.setInputType(InputType.TYPE_CLASS_NUMBER); input.setRawInputType(Configuration.KEYBOARD_12KEY); DialogInterface.OnClickListener positive = (dialog, whichButton) -> { if (input.getText().length() > 0) parent.goToPage(Integer.parseInt(input.getText().toString())); }; AlertDialog materialDialog = new MaterialAlertDialogBuilder(requireContext()) .setView(input) .setPositiveButton(android.R.string.ok, positive) .setNegativeButton(android.R.string.cancel, null) .create(); materialDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); return materialDialog; }
Example #26
Source File: EditProfileActivity.java From Aria2App with GNU General Public License v3.0 | 6 votes |
private void setDefaultCondition() { int def = findDefaultCondition(); if (def == -1) { setDefaultCondition(0); def = 0; } AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); builder.setTitle(R.string.setDefaultCondition) .setSingleChoiceItems(new RadioConditionsAdapter(this, conditionsList()), def, (dialog, which) -> { setDefaultCondition(which); dialog.dismiss(); }) .setNegativeButton(android.R.string.cancel, null); showDialog(builder); }
Example #27
Source File: UrisFragment.java From Aria2App with GNU General Public License v3.0 | 6 votes |
private void showAddUriDialog(final int oldPos, @Nullable String edit) { if (getContext() == null) return; final EditText uri = new EditText(getContext()); uri.setInputType(InputType.TYPE_TEXT_VARIATION_URI); uri.setText(edit); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle(edit == null ? R.string.addUri : R.string.editUri) .setView(uri) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(edit == null ? R.string.add : R.string.save, (dialog, which) -> { if (uri.getText().toString().trim().startsWith("magnet:") && !adapter.getUris().isEmpty()) { showToast(Toaster.build().message(R.string.onlyOneTorrentUri)); return; } if (oldPos != -1) adapter.removeUri(oldPos); adapter.addUri(uri.getText().toString()); }); showDialog(builder); }
Example #28
Source File: Dialogs.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
@NonNull @SuppressLint("InflateParams") public static MaterialAlertDialogBuilder notEnoughCards(@NonNull Context context, @NonNull PyxException ex) throws JSONException { LinearLayout layout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.dialog_cannot_start_game, null, false); int wcr = ex.obj.getInt("wcr"); int bcr = ex.obj.getInt("bcr"); int wcp = ex.obj.getInt("wcp"); int bcp = ex.obj.getInt("bcp"); ((TextView) layout.findViewById(R.id.cannotStartGame_wcr)).setText(String.valueOf(wcr)); ((TextView) layout.findViewById(R.id.cannotStartGame_bcr)).setText(String.valueOf(bcr)); ((TextView) layout.findViewById(R.id.cannotStartGame_wcp)).setText(String.valueOf(wcp)); ((TextView) layout.findViewById(R.id.cannotStartGame_bcp)).setText(String.valueOf(bcp)); ((ImageView) layout.findViewById(R.id.cannotStartGame_checkBc)).setImageResource(bcp >= bcr ? R.drawable.baseline_done_24 : R.drawable.baseline_clear_24); ((ImageView) layout.findViewById(R.id.cannotStartGame_checkWc)).setImageResource(wcp >= wcr ? R.drawable.baseline_done_24 : R.drawable.baseline_clear_24); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); builder.setTitle(R.string.cannotStartGame) .setView(layout) .setPositiveButton(android.R.string.ok, null); return builder; }
Example #29
Source File: LoadingActivity.java From Aria2App with GNU General Public License v3.0 | 5 votes |
private void showErrorDialog(@NonNull final Throwable ex) { AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); builder.setTitle(R.string.failedConnecting) .setPositiveButton(android.R.string.ok, null) .setNeutralButton(R.string.contactMe, (dialog, which) -> LogsHelper.sendEmail(LoadingActivity.this, ex)) .setMessage(ex.toString()); showDialog(builder); }
Example #30
Source File: WebViewActivity.java From Aria2App with GNU General Public License v3.0 | 5 votes |
private void showGoToDialog(boolean compulsory) { EditText input = new EditText(this); input.setSingleLine(true); input.setHint(R.string.webViewUrlHint); input.setInputType(InputType.TYPE_TEXT_VARIATION_URI); AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); builder.setTitle(R.string.goTo) .setView(input) .setCancelable(!compulsory) .setNeutralButton(R.string.setAsDefault, (dialog, which) -> { String text = input.getText().toString(); if (text.isEmpty()) { Prefs.remove(PK.WEBVIEW_HOMEPAGE); return; } Prefs.putString(PK.WEBVIEW_HOMEPAGE, guessUrl(text)); web.loadUrl(guessUrl(text)); ThisApplication.sendAnalytics(Utils.ACTION_WEBVIEW_SET_HOMEPAGE); }) .setPositiveButton(R.string.visit, (dialog, which) -> web.loadUrl(guessUrl(input.getText().toString()))); if (compulsory) builder.setNegativeButton(android.R.string.cancel, (d, i) -> onBackPressed()); else builder.setNegativeButton(android.R.string.cancel, null); showDialog(builder); }