/** * helper method to open the license dialog / or website * * @param ctx Context for startActivity * @param libsBuilder * @param library */ private void openLicense(Context ctx, LibsBuilder libsBuilder, Library library) { try { if (libsBuilder.showLicenseDialog && !TextUtils.isEmpty(library.getLicense().getLicenseDescription())) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(Html.fromHtml(library.getLicense().getLicenseDescription())); builder.create().show(); } else { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(library.getLicense().getLicenseWebsite())); ctx.startActivity(browserIntent); } } catch (Exception ex) { } }
@Override public void onClick(View v) { boolean consumed = false; if (LibsConfiguration.getInstance().getListener() != null) { consumed = LibsConfiguration.getInstance().getListener().onExtraClicked(v, Libs.SpecialButton.SPECIAL1); } if (!consumed && !TextUtils.isEmpty(libsBuilder.aboutAppSpecial1Description)) { try { AlertDialog alert = new AlertDialog.Builder(ctx) .setMessage(Html.fromHtml(libsBuilder.aboutAppSpecial1Description)) .create(); alert.show(); TextView alertText = (TextView) alert.findViewById(android.R.id.message); if (alertText != null) { alertText.setMovementMethod(LinkMovementMethod.getInstance()); } } catch (Exception ex) { } } } });
@Override public void onClick(View v) { boolean consumed = false; if (LibsConfiguration.getInstance().getListener() != null) { consumed = LibsConfiguration.getInstance().getListener().onExtraClicked(v, Libs.SpecialButton.SPECIAL3); } if (!consumed && !TextUtils.isEmpty(libsBuilder.aboutAppSpecial3Description)) { try { AlertDialog alert = new AlertDialog.Builder(ctx) .setMessage(Html.fromHtml(libsBuilder.aboutAppSpecial3Description)) .create(); alert.show(); TextView alertText = (TextView) alert.findViewById(android.R.id.message); if (alertText != null) { alertText.setMovementMethod(LinkMovementMethod.getInstance()); } } catch (Exception ex) { } } } });
@Override public void onClick(View v) { boolean consumed = false; if (LibsConfiguration.getInstance().getListener() != null) { consumed = LibsConfiguration.getInstance().getListener().onExtraClicked(v, Libs.SpecialButton.SPECIAL2); } if (!consumed && !TextUtils.isEmpty(libsBuilder.aboutAppSpecial2Description)) { try { AlertDialog alert = new AlertDialog.Builder(ctx) .setMessage(Html.fromHtml(libsBuilder.aboutAppSpecial2Description)) .create(); alert.show(); TextView alertText = (TextView) alert.findViewById(android.R.id.message); if (alertText != null) { alertText.setMovementMethod(LinkMovementMethod.getInstance()); } } catch (Exception ex) { } } } });
/** * Start the dialog and display it on screen. The window is placed in the * application layer and opaque. Note that you should not override this * method to do initialization when the dialog is shown, instead implement * that in {@link #onStart}. */ public void show() { if (mRecyclerView.getLayoutManager() == null) { mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); } initAdapterIfNeeded(); super.show(); }
@Override public void onClick() { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(c); alertBuilder.setTitle(dialogTitle); final WebView wv = new WebView(c); wv.getSettings().setSupportZoom(supportZoom); if (!supportZoom) { wv.getSettings().setLoadWithOverviewMode(true); wv.getSettings().setUseWideViewPort(true); } if (isStringUrl) { wv.loadUrl(htmlString); } else { wv.loadData(htmlString, "text/html; charset=utf-8", "UTF-8"); } alertBuilder.setView(wv); alertBuilder.setNegativeButton(dialogNegativeButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { wv.destroy(); dialog.dismiss(); } }); final AlertDialog dialog = alertBuilder.create(); dialog.show(); } };
.create(); dialog.show();
private void requestLocationSettingsToBeOn() { if(LocationUtil.isLocationOn(getContext())) { state = LocationState.ENABLED; nextStep(); } else { final AlertDialog dlg = new AlertDialog.Builder(getContext()) .setMessage(R.string.turn_on_location_request) .setPositiveButton(android.R.string.yes, (dialog, which) -> { dialog.dismiss(); Intent viewIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(viewIntent, LOCATION_TURN_ON_REQUEST); }) .setNegativeButton(android.R.string.no, (dialog, which) -> cancelTurnLocationOnDialog()) .setOnCancelListener(dialog -> cancelTurnLocationOnDialog()) .create(); // the user may turn on location in the pull-down-overlay, without actually going into // settings dialog registerForLocationProviderChanges(dlg); dlg.show(); } }
private void displayPurchase(long price) { AlertDialog.Builder builder = new AlertDialog.Builder(this); View dialogView = LayoutInflater.from(this) .inflate(R.layout.purchase_complete_notification, null); TextView emojiView = dialogView.findViewById(R.id.dlg_emoji_display); // Show a smiley face! emojiView.setText(StoreUtils.getEmojiByUnicode(0x1F642)); TextView priceView = dialogView.findViewById(R.id.dlg_price_display); priceView.setText(StoreUtils.getPriceString(price, null)); builder.setView(dialogView); AlertDialog dialog = builder.create(); dialog.show(); }
private void show_noVideo_dialog() { AlertDialog dialog = new AlertDialog.Builder(context/**/).create(); dialog.setTitle(context.getString(R.string.error_no_video)); dialog.setMessage(context.getString(R.string.error_select_video_and_retry)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok).toUpperCase(), (dialog1, buttonId) -> dialog1.dismiss()); dialog.show(); }
private void showDialog(AlertDialog dialog) { if (mCurrentDialog != null) mCurrentDialog.dismiss(); mCurrentDialog = dialog; dialog.setOnDismissListener((DialogInterface i) -> { mCurrentDialog = null; showDialogsIfNeeded(); }); dialog.show(); }
private void showError(@NonNull String error) { AlertDialog alertDialog = new AlertDialog.Builder(this) .setMessage(error) .setCancelable(true) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }) .create(); alertDialog.show(); }
private void displayError(String errorMessage) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Error"); alertDialog.setMessage(errorMessage); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
private void performRestore() { //noinspection ConstantConditions AlertDialog dialog = new AlertDialog.Builder(getContext()) .setTitle(R.string.change_edit_restore_file_title) .setMessage(R.string.change_edit_restore_file_message) .setPositiveButton(R.string.action_restore, (dialogInterface, i) -> restoreFile()) .setNegativeButton(R.string.action_cancel, null) .create(); dialog.show(); }
private void showLeaveChatRoomDialog() { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.leave_chat_room) .setMessage(getResources().getString(R.string.leave_chat_room_body)) .setPositiveButton(R.string.leave, (dialogInterface, i) -> leaveChatRoom()) .setNegativeButton(android.R.string.cancel, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showError(String message) { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(getString(R.string.error)) .setMessage(message) .setPositiveButton(R.string.ok, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showErrorDialog(String message) { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.error) .setMessage(message) .setIcon(R.drawable.ic_error_outline) .setPositiveButton(R.string.ok, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void displayCloseDialog() { AlertDialog dialog = new AlertDialog.Builder(this) .setMessage(R.string.discard_changes_question) .setNegativeButton(R.string.discard, (dialogInterface, which) -> finish()) .setPositiveButton(R.string.keep_editing, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showLogoutDialog() { AlertDialog dialog = new AlertDialog.Builder(mContext) .setMessage(R.string.logout_message) .setPositiveButton(R.string.logout, ((dialogInterface, i) -> logout())) .setNegativeButton(R.string.cancel, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void performPublishEdit() { readFileContent(() -> { //noinspection ConstantConditions AlertDialog dialog = new AlertDialog.Builder(getContext()) .setTitle(R.string.change_edit_publish_title) .setMessage(R.string.change_edit_publish_message) .setPositiveButton(R.string.action_publish, (dialogInterface, i) -> requestPublishEdit()) .setNegativeButton(R.string.action_cancel, null) .create(); dialog.show(); }); }