@Optional @OnClick(R.id.delete) void deleteScriptFile() { dismissDialogs(); new MaterialDialog.Builder(getActivity()) .title(R.string.delete_confirm) .positiveText(R.string.cancel) .negativeText(R.string.ok) .onNegative(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { doDeletingScriptFile(); } }) .show(); }
@Override public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { if (mIsFirstTextChanged) { mIsFirstTextChanged = false; return; } EditText editText = dialog.getInputEditText(); if (editText == null) return; int errorResId = 0; if (input == null || input.length() == 0) { errorResId = R.string.text_name_should_not_be_empty; } else if (!input.equals(mExcluded)) { if (new File(getCurrentDirectory(), mIsDirectory ? input.toString() : input.toString() + ".js").exists()) { errorResId = R.string.text_file_exists; } } if (errorResId == 0) { editText.setError(null); dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true); } else { editText.setError(getString(errorResId)); dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false); } }
public ScriptLoopDialog(Context context, ScriptFile file) { mScriptFile = file; View view = View.inflate(context, R.layout.dialog_script_loop, null); mDialog = new MaterialDialog.Builder(context) .title(R.string.text_run_repeatedly) .customView(view, true) .positiveText(R.string.ok) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { startScriptRunningLoop(); } }) .build(); ButterKnife.bind(this, view); }
private Observable<String> showNameInputDialog(String prefix, MaterialDialog.InputCallback textWatcher) { final PublishSubject<String> input = PublishSubject.create(); DialogUtils.showDialog(new ThemeColorMaterialDialogBuilder(mContext).title(R.string.text_name) .inputType(InputType.TYPE_CLASS_TEXT) .alwaysCallInputCallback() .input(getString(R.string.text_please_input_name), prefix, false, textWatcher) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { input.onNext(dialog.getInputEditText().getText().toString()); input.onComplete(); } }) .build()); return input; }
@Override public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { if (mIsFirstTextChanged) { mIsFirstTextChanged = false; return; } EditText editText = dialog.getInputEditText(); if (editText == null) return; int errorResId = 0; if (input == null || input.length() == 0) { errorResId = R.string.text_name_should_not_be_empty; } else if (!input.equals(mExcluded)) { if (new File(getCurrentDirectory(), mExtension == null ? input.toString() : input.toString() + mExtension).exists()) { errorResId = R.string.text_file_exists; } } if (errorResId == 0) { editText.setError(null); dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true); } else { editText.setError(getString(errorResId)); dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false); } }
@Override public void onClick(View v) { if (v.getTag() != null) { final String[] tag = ((String) v.getTag()).split(":"); final int index = Integer.parseInt(tag[0]); final MaterialDialog dialog = (MaterialDialog) getDialog(); final Builder builder = getBuilder(); if (isInSub()) { subIndex(index); } else { topIndex(index); if (mColorsSub != null && index < mColorsSub.length) { dialog.setActionButton(DialogAction.NEGATIVE, builder.mBackBtn); isInSub(true); } } if (builder.mAllowUserCustom) selectedCustomColor = getSelectedColor(); invalidateDynamicButtonColors(); invalidate(); } }
@OnClick(R.id.input_custominvalidation) public void showInputDialogCustomInvalidation() { new MaterialDialog.Builder(this) .title(R.string.input) .content(R.string.input_content_custominvalidation) .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME | InputType.TYPE_TEXT_FLAG_CAP_WORDS) .positiveText(R.string.submit) .alwaysCallInputCallback() // this forces the callback to be invoked with every input change .input(R.string.input_hint, 0, false, (dialog, input) -> { if (input.toString().equalsIgnoreCase("hello")) { dialog.setContent("I told you not to type that!"); dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false); } else { dialog.setContent(R.string.input_content_custominvalidation); dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true); } }).show(); }
private void showAppUpdateDialog(final Activity activity, final AppRelease release) { new MaterialDialog .Builder(activity) .title("新版本:"+release.getVersionName()) .content(release.getReleaseNotes()) .positiveText("立即下载") .negativeText("以后再说") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { UpdateService.Builder.create(release.getSourceFileUrl()).build(activity); } }) .show(); }
private void showDeleteConfirmDialog() { new MaterialDialog .Builder(getActivity()) .title("确认删除") .content("真的要将这" + bookcaseAdapter.getSelectedBookTbs().size() + "本书从书架中删除吗?") .positiveText("删除") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { getPresenter().deleteItems(bookcaseAdapter.getSelectedBookTbs()); toggleEditMenu(); bookcaseAdapter.cancelEdit(); } }) .negativeText("取消") .show(); }
@Override public void onBackPressed() { new MaterialDialog.Builder(this) .content(R.string.exitAlert) .negativeText(R.string.no) .positiveText(R.string.yes) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { new EndpointInBackGround().execute(Message.REQUEST_EXIT_GROUP); Intent intent = new Intent(getApplicationContext(), ClipboardService.class); stopService(intent); GroupActivity.super.onBackPressed(); } }) .show(); }
public void showFirstRunDialog() { MaterialDialog frDialog = new MaterialDialog.Builder(this) .title(getString(R.string.welcome_app_dialog_title)) .content(getString(R.string.welcome_app_text)) .positiveText(getString(R.string.welcome_app_dialog_positive_text)) .cancelable(false) .autoDismiss(false) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); Prefs.putBoolean("firstRun", false); } }) .build(); frDialog.show(); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { //noinspection unchecked final AbsSmartPlaylist playlist = getArguments().getParcelable("playlist"); int title = R.string.clear_playlist_title; //noinspection ConstantConditions CharSequence content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist.name)); return new MaterialDialog.Builder(getActivity()) .title(title) .content(content) .positiveText(R.string.clear_action) .negativeText(android.R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { if (getActivity() == null) { return; } playlist.clear(getActivity()); } }) .build(); }
@Override public void show500ServerError() { builder = new MaterialDialog.Builder(mContext) .title(R.string.all_dialog_server_error) .content(R.string.all_dialog_try_again) .positiveText(R.string.all_dialog_positive).onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }); dialog = builder.build(); dialog.show(); dialog.setCanceledOnTouchOutside(false); }
@Override public void showNoInternetConnectionError() { builder = new MaterialDialog.Builder(mContext) .title(R.string.all_dialog_connection_error_title) .content(R.string.all_dialog_connection_error_content) .positiveText(R.string.all_dialog_positive).onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }); dialog = builder.build(); dialog.show(); dialog.setCanceledOnTouchOutside(false); }
@Override public void showSuccessDialog() { builder = new MaterialDialog.Builder(mContext) .title(R.string.view_single_dialog_title_success) .content(R.string.view_single_dialog_content_success) .positiveText(R.string.view_single_dialog_positive_continue).onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); startActivity(new Intent(mContext, NearbyProductsActivity.class)); overridePendingTransition(R.anim.left_out, R.anim.right_in); } }); dialog = builder.build(); dialog.show(); dialog.setCanceledOnTouchOutside(false); }
@Override public void showSuccessDialog() { builder = new MaterialDialog.Builder(mContext) .title("Success") .content("Your listing has been updated!") .positiveText("Continue").onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); startActivity(new Intent(mContext, NearbyProductsActivity.class)); overridePendingTransition(R.anim.left_out, R.anim.right_in); } }); dialog = builder.build(); dialog.show(); dialog.setCanceledOnTouchOutside(false); }
@Override public void showTimeOutError() { builder = new MaterialDialog.Builder(mContext) .title("Timeout Error") .content("Please check your internet connection and try again.") .positiveText("Aceptar").onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }); dialog = builder.build(); dialog.show(); dialog.setCanceledOnTouchOutside(false); }
@Override public void showNetworkError() { builder = new MaterialDialog.Builder(mContext) .title(R.string.all_dialog_network_error_title) .content(R.string.all_dialog_try_again) .positiveText(R.string.all_dialog_positive).onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }); dialog = builder.build(); dialog.show(); dialog.setCanceledOnTouchOutside(false); }
@Override public void showSuccessDialog() { builder = new MaterialDialog.Builder(mContext) .title(R.string.view_single_dialog_title_success) .content(R.string.nearby_dialog_listing_created) .positiveText(R.string.view_single_dialog_positive_continue).onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); startActivity(new Intent(mContext, NearbyProductsActivity.class)); overridePendingTransition(R.anim.left_out, R.anim.right_in); } }); dialog = builder.build(); dialog.show(); dialog.setCanceledOnTouchOutside(false); }
@Override public void showRequiredImagesDialog() { builder = new MaterialDialog.Builder(mContext) .title(R.string.new_item_dialog_title_missing_image) .content(R.string.new_item_dialog_content_missing_image) .positiveText(R.string.all_dialog_positive).onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }); dialog = builder.build(); dialog.show(); dialog.setCanceledOnTouchOutside(false); }
@Override public void showTimeOutError() { builder = new MaterialDialog.Builder(mContext) .title(R.string.all_dialog_timeout_error_title) .content(R.string.all_dialog_timeout_error_content) .positiveText(R.string.all_dialog_positive).onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }); dialog = builder.build(); dialog.show(); dialog.setCanceledOnTouchOutside(false); }
@Override public void onBackPressed() { new MaterialDialog.Builder(this) .title(R.string.ok) .content(R.string.are_you_finish_app) .positiveText(R.string.finish) .negativeText(R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { Intent intent = new Intent(getApplicationContext(), StartActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("EXIT", true); startActivity(intent); finish(); } }) .show(); }
private void showNeedPermissionDialog(){ new MaterialDialog.Builder(this) .title(R.string.check_srt) .content(R.string.required_permission) .positiveText(R.string.ok) .negativeText(R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { Intent myAppSettings = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + getPackageName())); myAppSettings.addCategory(Intent.CATEGORY_DEFAULT); myAppSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(myAppSettings); } }) .show(); }
public void logout(Activity activity){ new MaterialDialog.Builder(activity) .title(R.string.ok) .content(R.string.are_you_sure_logout) .positiveText(R.string.logout) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { SharedPreferences.Editor editor = getSharedPreferences("setting", 0).edit(); editor.putString("login_id", null); editor.putString("login_pw", null); editor.putBoolean("isEmployee", false); editor.commit(); StartActivity.initLoginData(); Intent intent = new Intent(getApplicationContext(), StartActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } }) .negativeText(R.string.cancel) .show(); }
public void selectMedicine(final Medicine medicine){ String content = ""; content = "이 약을 새롭게 추가하겠습니까?\n\n" + "약명 : " + medicine.getName() + "\n" + "보험코드 : " + medicine.getCode() + "\n" + "제조회사 : " + medicine.getCompany() + "\n" + "용량 : " + medicine.getStandard() + medicine.getUnit(); new MaterialDialog.Builder(this) .title(R.string.ok) .content(content) .positiveText(R.string.ok) .negativeText(R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { Intent intent = new Intent(); intent.putExtra("medicine", medicine); setResult(SELECTED_MEDICINE, intent); finish(); } }) .show(); }
/** * When Material Dialog on click occurs */ @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { if(mNavigationIndex == R.id.nav_anime || mNavigationIndex == R.id.nav_manga || mNavigationIndex == R.id.nav_myanime || mNavigationIndex == R.id.nav_mymanga || mNavigationIndex == R.id.nav_hub) { mPresenter.createSuperToast(MainActivity.this, getString(R.string.text_filter_applying), R.drawable.ic_reset, Style.TYPE_PROGRESS_BAR, Style.DURATION_VERY_SHORT, PaletteUtils.getSolidColor(PaletteUtils.MATERIAL_CYAN)); } else { mPresenter.createSuperToast(MainActivity.this, getString(R.string.text_filter_restriction), R.drawable.ic_info_outline_white_18dp, Style.TYPE_STANDARD, Style.DURATION_VERY_SHORT, PaletteUtils.getSolidColor(PaletteUtils.MATERIAL_ORANGE)); } }
public void requestAppReset() { new DialogManager(mContext).createDialogMessage("Authentication Error", Html.fromHtml(mContext.getString(R.string.app_splash_authenticating_message)), mContext.getString(R.string.Yes), mContext.getString(R.string.No), new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { switch (which) { case POSITIVE: makeAlerterInfo("Application has been reset!"); ServiceGenerator.authStateChange(mContext); new ApplicationPrefs(mContext).setUserDeactivated(); mContext.onRefresh(); break; case NEGATIVE: dialog.dismiss(); break; } } }); }
public void createDialogSelection(String title , int selection, MaterialDialog.ListCallbackSingleChoice callbackSingleChoice, MaterialDialog.SingleButtonCallback positive, int index){ new MaterialDialog.Builder(mContext) .title(title) .items(selection) .typeface(Typeface.SANS_SERIF,Typeface.SANS_SERIF) .iconRes(app_prefs.isLightTheme()?R.drawable.ic_view_list_black_24dp:R.drawable.ic_view_list_white_24dp) .buttonRippleColorRes(R.color.colorAccent) .positiveColorRes(R.color.colorStateBlue) .negativeColorRes(R.color.colorStateOrange) .theme(app_prefs.isLightTheme()?Theme.LIGHT:Theme.DARK) .itemsCallbackSingleChoice(index, callbackSingleChoice) .positiveText(R.string.Apply) .neutralText(R.string.Cancel) .onPositive(positive) .onNeutral(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }) .show(); }
public void createDialogSelection(String title, Collection selection, MaterialDialog.ListCallbackSingleChoice callbackSingleChoice, MaterialDialog.SingleButtonCallback positive, int index){ new MaterialDialog.Builder(mContext) .title(title) .items(selection) .typeface(Typeface.SANS_SERIF,Typeface.SANS_SERIF) .iconRes(app_prefs.isLightTheme()?R.drawable.ic_view_list_black_24dp:R.drawable.ic_view_list_white_24dp) .buttonRippleColorRes(R.color.colorAccent) .positiveColorRes(R.color.colorStateBlue) .negativeColorRes(R.color.colorStateOrange) .theme(app_prefs.isLightTheme()?Theme.LIGHT:Theme.DARK) .itemsCallbackSingleChoice(index, callbackSingleChoice) .positiveText(R.string.Apply) .neutralText(R.string.Cancel) .onPositive(positive) .onNeutral(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }) .show(); }
public void checkErrors() { new MaterialDialog.Builder(LModActivity.this) .title(R.string.dialog_premium_version) .content(R.string.dialog_only_in_premium) .positiveText(R.string.buy_premium) .negativeText(R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.premium_url)))); } }) .show(); }
/** 打开辅助服务的设置 */ private void openAccessibilityServiceSettings() { new MaterialDialog.Builder(this) .title(R.string.open_service_title) .customView(R.layout.view_open_service_hint, false) .positiveText(R.string.open_service_button) .onAny(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { switch (which) { case POSITIVE: try { Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); startActivity(intent); ToastUtils.show("找到[快手抢红包],然后开启服务即可"); } catch (Exception e) { LogUtils.e(e); } break; } } }) .show(); }
private void exit() { if(!QHBService.isRun()){ AppManager.getInstance().exitApp(true); return; } new MaterialDialog.Builder(getActivity()) .title("退出服务") .content("找到[快手抢红包],然后关闭服务再退出即可") .negativeText("取消") .positiveText("确认") .onAny(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { switch (which) { case POSITIVE: getActivity().startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)); break; } } }) .show(); }
public void onClickChatLandScapeWidth(View v) { final int landscapeWidth = settings.getChatLandscapeWidth(); DialogService.getSliderDialog( this, new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { settings.setChatLandscapeWidth(landscapeWidth); updateSummaries(); } }, new Slider.OnPositionChangeListener() { @Override public void onPositionChanged(Slider view, boolean fromUser, float oldPos, float newPos, int oldValue, int newValue) { settings.setChatLandscapeWidth(newValue); updateSummaries(); } }, landscapeWidth, 25, 60, getString(R.string.chat_landscape_width_dialog) ).show(); }