com.afollestad.materialdialogs.DialogAction Java Examples
The following examples show how to use
com.afollestad.materialdialogs.DialogAction.
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: SharedPreferenceActivity.java From MagicalCamera with Apache License 2.0 | 6 votes |
private View popUpLayout(final int idLayout) { MaterialDialog dialog = new MaterialDialog.Builder(this) .title(R.string.shared_change_color) .customView(idLayout, true) .positiveText(R.string.shared_accept) .autoDismiss(false) .backgroundColor(getResources().getColor(R.color.colorWhite)) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) { materialDialog.dismiss(); materialDialog.cancel(); } }) .show(); return dialog.getCustomView(); }
Example #2
Source File: IabUtil.java From oversec with GNU General Public License v3.0 | 6 votes |
public synchronized void doIfFullOrShowPurchaseDialog(final Fragment fragment, final Runnable okRunnable, final int requestCode) { checkFullVersion(new FullVersionListener() { @Override public void onFullVersion_MAIN_THREAD(boolean isFullVersion) { if (isFullVersion) { okRunnable.run(); } else { makePurchaseDialog(fragment.getActivity()) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { showPurchaseActivity(fragment, requestCode); } }) .show(); } } }); }
Example #3
Source File: MJavascriptInterface.java From Focus with GNU General Public License v3.0 | 6 votes |
@android.webkit.JavascriptInterface public void openUrl(final String url) { new MaterialDialog.Builder(activity) .title("即将前往") .content("点击「确定」将会访问该链接地址") .positiveText("确定") .negativeText("取消") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { WebViewUtil.openLink(url, (Activity) activity); } }) .show(); }
Example #4
Source File: ActivityManageSpaceViewModel.java From iGap-Android with GNU Affero General Public License v3.0 | 6 votes |
public void onClickSdkEnable(View view) { new MaterialDialog.Builder(context) .title(G.context.getResources().getString(R.string.are_you_sure)) .negativeText(G.context.getResources().getString(R.string.B_cancel)) .content(G.context.getResources().getString(R.string.change_storage_place)) .positiveText(G.context.getResources().getString(R.string.B_ok)) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { isSdkEnable.set(!isSdkEnable.get()); } }).show(); }
Example #5
Source File: SettingsTwitchChatActivity.java From Pocket-Plays-for-Twitch with GNU General Public License v3.0 | 6 votes |
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(); }
Example #6
Source File: MainActivity.java From Ency with Apache License 2.0 | 6 votes |
/** * 检查更新提示框 */ @Override public void showUpdateDialog(final UpdateBean updateBean) { if (null != updateBean) { new MaterialDialog.Builder(mContext) .title(R.string.app_update) .content("最新版本:" + updateBean.getVersionShort() + "\n" + "版本大小:" + SystemUtil.getFormatSize(updateBean.getBinary().getFsize()) + "\n" + "更新内容:" + updateBean.getChangelog()) .negativeText(R.string.no) .negativeColorRes(R.color.colorNegative) .positiveText(R.string.update) .positiveColorRes(R.color.colorPositive) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { showMsg(getResources().getString(R.string.start_update)); Intent intent = new Intent(mContext, UpdateService.class); intent.putExtra("downloadurl", updateBean.getInstall_url()); startService(intent); } }) .show(); } }
Example #7
Source File: MJavascriptInterface.java From Focus with GNU General Public License v3.0 | 6 votes |
@android.webkit.JavascriptInterface public void openUrl(final String url) { new MaterialDialog.Builder(activity) .title("即将前往") .content("点击「确定」将会访问该链接地址") .positiveText("确定") .negativeText("取消") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { WebViewUtil.openLink(url, (Activity) activity); } }) .show(); }
Example #8
Source File: ClearSmartPlaylistDialog.java From RetroMusicPlayer with GNU General Public License v3.0 | 6 votes |
@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(); }
Example #9
Source File: CommonModel.java From Fishing with GNU General Public License v3.0 | 6 votes |
private void showUpdateDialog(Context ctx,String versionName,String content,String url){ new MaterialDialog.Builder(ctx) .title("新版本 "+versionName) .content(content) .positiveText("立即升级") .negativeText("取消") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) { JUtils.Log("Get Start"); Intent updateIntent = new Intent(ctx, UpdateService.class); updateIntent.putExtra("title", "空钩正在更新"); updateIntent.putExtra("url", url); updateIntent.putExtra("path", findDownLoadDirectory()); updateIntent.putExtra("name", ctx.getString(R.string.app_name) + "v" + versionName + ".apk"); ctx.startService(updateIntent); } }) .show(); }
Example #10
Source File: MainActivity.java From APKMirror with GNU General Public License v2.0 | 6 votes |
@Override public void onDownloadRequested(String url, String suggestedFilename, String mimeType, long contentLength, String contentDisposition, String userAgent) { if (isWritePermissionGranted()) { download(url, suggestedFilename); } else { new MaterialDialog.Builder(MainActivity.this) .title(R.string.write_permission) .content(R.string.storage_access) .positiveText(R.string.request_permission) .negativeText(android.R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { //Request permission ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); } }) .show(); } }
Example #11
Source File: FailHardActivity.java From GreenBits with GNU General Public License v3.0 | 6 votes |
@Override protected void onResume() { super.onResume(); final Intent i = getIntent(); Log.e(TAG, i.getStringExtra("errorTitle") + ':' + i.getStringExtra("errorContent")); UI.popup(this, i.getStringExtra("errorTitle")) .content(i.getStringExtra("errorContent")) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(final MaterialDialog dlg, final DialogAction which) { final Intent main = new Intent(Intent.ACTION_MAIN); main.addCategory(Intent.CATEGORY_HOME); main.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(main); finish(); } }).build().show(); }
Example #12
Source File: IabUtil.java From oversec with GNU General Public License v3.0 | 6 votes |
public synchronized void doIfFullOrShowPurchaseDialog(final Activity activity, final Runnable okRunnable, final int requestCode) { checkFullVersion(new FullVersionListener() { @Override public void onFullVersion_MAIN_THREAD(boolean isFullVersion) { if (isFullVersion) { okRunnable.run(); } else { makePurchaseDialog(activity) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { showPurchaseActivity(activity, requestCode); } }) .show(); } } }); }
Example #13
Source File: BulkReadCardsDialogFragment.java From Walrus with GNU General Public License v3.0 | 6 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { cardDataIOView = new CardDataIOView(getActivity()); cardDataIOView.setDirection(true); return new MaterialDialog.Builder(getActivity()) .title(R.string.bulk_reading_cards) .customView(cardDataIOView, false) .positiveText(R.string.stop_button) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { BulkReadCardDataOperationRunner runner = getRunner(); if (runner != null) { runner.stopReading(); } } }) .build(); }
Example #14
Source File: ComponentDialogFragment.java From Walrus with GNU General Public License v3.0 | 6 votes |
@Override public void onComponentChange(Component changedComponent) { if (getArguments().getBoolean("editable")) { ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled( component.isValid()); } problemViewGroup.removeAllViews(); if (!component.getProblems().isEmpty()) { problemViewGroup.addView(MultiComponent.createSpacer(getActivity())); for (String problem : new TreeSet<>(component.getProblems())) { TextView problemMessageView = new TextView(getActivity()); problemViewGroup.addView(problemMessageView); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getActivity().getResources().getDisplayMetrics()); problemMessageView.setPadding(0, padding, 0, padding); problemMessageView.setText(problem); problemMessageView.setTextColor(ContextCompat.getColor(getActivity(), android.R.color.holo_red_light)); } } }
Example #15
Source File: GeneralDialogCreation.java From PowerFileExplorer with GNU General Public License v3.0 | 6 votes |
public static void showHistoryDialog(final DataUtils dataUtils, Futils utils, final ContentFragment m, AppTheme appTheme) { int accentColor = m.activity.getColorPreference().getColor(ColorUsage.ACCENT); final MaterialDialog.Builder a = new MaterialDialog.Builder(m.getActivity()); a.positiveText(R.string.cancel); a.positiveColor(accentColor); a.negativeText(R.string.clear); a.negativeColor(accentColor); a.title(R.string.history); a.onNegative(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dataUtils.clearHistory(); } }); a.theme(appTheme.getMaterialDialogTheme()); a.autoDismiss(true); HiddenAdapter adapter = new HiddenAdapter(m.getActivity(), m, utils, R.layout.bookmarkrow, toHFileArray(dataUtils.getHistory()), null, true); a.adapter(adapter, null); MaterialDialog x= a.build(); adapter.updateDialog(x); x.show(); }
Example #16
Source File: CategorySelectionFragment.java From SimpleNews with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.share_categories: shareCategories(mCategories); return true; case R.id.restore_categories: new MaterialDialog.Builder(getActivity()) .title(R.string.restore_categories_title) .content(R.string.restore_categories_message) .positiveText(R.string.restore_categories_yes) .negativeText(R.string.restore_categories_no) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { DatabaseHandler.getInstance().removeAllCategories(); PrefUtilities.getInstance().saveLoading(false); onRestore(); } }).show(); return true; } return super.onOptionsItemSelected(item); }
Example #17
Source File: FragmentPlayer.java From uPods-android with Apache License 2.0 | 6 votes |
private void askPhoneStatePermissions() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Prefs.getBoolean(PREF_PHONE_PERM_ASKED, false)) { Prefs.putBoolean(PREF_PHONE_PERM_ASKED, true); new MaterialDialog.Builder(getActivity()) .title(R.string.phone_state_permissions) .content(R.string.phone_state_description) .positiveText(R.string.ok) .onAny(new MaterialDialog.SingleButtonCallback() { @TargetApi(Build.VERSION_CODES.M) @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { getActivity().requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, CODE_PERMISSIONS_PHONE_STATE); } }).build().show(); } }
Example #18
Source File: ColorChooserDialog.java From APlayer with GNU General Public License v3.0 | 6 votes |
@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) { mSelectedCustomColor = getSelectedColor(); } invalidateDynamicButtonColors(); invalidate(); } }
Example #19
Source File: BleDevicesFragment.java From bleYan with GNU General Public License v2.0 | 6 votes |
public void displayPromptForEnablingGPS() { final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS; new MaterialDialog.Builder(getActivity()) .title(R.string.label_request_open_gps_title) .content(R.string.label_request_open_gps_content) .positiveText(R.string.label_ok) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) { startActivityForResult(new Intent(action), REQUEST_CODE_OPEN_GPS); } }) .negativeText(R.string.label_cancel) .cancelable(true) .negativeText(R.string.label_cancel) .show(); }
Example #20
Source File: ClearSmartPlaylistDialog.java From Orin with GNU General Public License v3.0 | 6 votes |
@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(); }
Example #21
Source File: TSTaskActivity.java From Duolingo-Clone with MIT License | 6 votes |
@Override public void onBackPressed() { new MaterialDialog.Builder(this) .title("Are you sure about that?") .content("All progress in this lesson will be lost.") .positiveText("QUIT") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { progressBarValue = 0; Hawk.put("progressBarValue", progressBarValue); finish(); } }) .negativeText("CANCEL") .show(); }
Example #22
Source File: TapPairActivity.java From Duolingo-Clone with MIT License | 6 votes |
@Override public void onBackPressed() { new MaterialDialog.Builder(this) .title("Are you sure about that?") .content("All progress in this lesson will be lost.") .positiveText("QUIT") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { progressBarValue = 0; Hawk.put("progressBarValue", progressBarValue); finish(); } }) .negativeText("CANCEL") .show(); }
Example #23
Source File: WordTaskActivity.java From Duolingo-Clone with MIT License | 6 votes |
@Override public void onBackPressed() { new MaterialDialog.Builder(this) .title("Are you sure about that?") .content("All progress in this lesson will be lost.") .positiveText("QUIT") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { progressBarValue = 0; Hawk.put("progressBarValue", progressBarValue); finish(); } }) .negativeText("CANCEL") .show(); }
Example #24
Source File: ReportBugsHelper.java From candybar-library with Apache License 2.0 | 6 votes |
public static void prepareReportBugs(@NonNull Context context) { MaterialDialog.Builder builder = new MaterialDialog.Builder(context); builder.customView(R.layout.dialog_report_bugs, true); builder.typeface( TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context)); builder.positiveText(R.string.report_bugs_send); builder.negativeText(R.string.close); MaterialDialog dialog = builder.build(); EditText editText = (EditText) dialog.findViewById(R.id.input_desc); TextInputLayout inputLayout = (TextInputLayout) dialog.findViewById(R.id.input_layout); dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(view -> { if (editText.getText().length() > 0) { inputLayout.setErrorEnabled(false); ReportBugsTask.start(context, editText.getText().toString(), AsyncTask.THREAD_POOL_EXECUTOR); dialog.dismiss(); return; } inputLayout.setError(context.getResources().getString(R.string.report_bugs_desc_empty)); }); dialog.show(); }
Example #25
Source File: FaultUtil.java From homeassist with Apache License 2.0 | 6 votes |
@SuppressWarnings("SameParameterValue") public static void showError(final Context context, String title, String content) { new MaterialDialog.Builder(context) .cancelable(false) .title(title) .content(content) .positiveText(R.string.button_continue) .positiveColorRes(R.color.md_red_500) .buttonRippleColorRes(R.color.md_grey_200) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { dialog.dismiss(); } }) .show(); }
Example #26
Source File: CommonUtil.java From homeassist with Apache License 2.0 | 6 votes |
public static void fixDialogKeyboard(final MaterialDialog dialog) { //https://github.com/afollestad/material-dialogs/issues/1105 EditText inputEditText = dialog.getInputEditText(); if (inputEditText != null) { inputEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE) || (actionId == EditorInfo.IME_ACTION_SEARCH)) { View positiveButton = dialog.getActionButton(DialogAction.POSITIVE); if (dialog.getActionButton(DialogAction.POSITIVE).isEnabled()) { positiveButton.callOnClick(); } else { return true; } } return false; } }); } }
Example #27
Source File: MainPresenter.java From FriendBook with GNU General Public License v3.0 | 6 votes |
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(); }
Example #28
Source File: BookcaseFragment.java From FriendBook with GNU General Public License v3.0 | 6 votes |
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(); }
Example #29
Source File: ReportBugsHelper.java From candybar with Apache License 2.0 | 6 votes |
public static void prepareReportBugs(@NonNull Context context) { MaterialDialog.Builder builder = new MaterialDialog.Builder(context); builder.customView(R.layout.dialog_report_bugs, true); builder.typeface( TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context)); builder.positiveText(R.string.report_bugs_send); builder.negativeText(R.string.close); MaterialDialog dialog = builder.build(); EditText editText = (EditText) dialog.findViewById(R.id.input_desc); TextInputLayout inputLayout = (TextInputLayout) dialog.findViewById(R.id.input_layout); dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(view -> { if (editText.getText().length() > 0) { inputLayout.setErrorEnabled(false); ReportBugsTask.start(context, editText.getText().toString(), AsyncTask.THREAD_POOL_EXECUTOR); dialog.dismiss(); return; } inputLayout.setError(context.getResources().getString(R.string.report_bugs_desc_empty)); }); dialog.show(); }
Example #30
Source File: TransactionActivity.java From GreenBits with GNU General Public License v3.0 | 5 votes |
private void openInBrowser(final TextView textView, final String identifier, final String url, final JSONMap confidentialData) { if (confidentialData == null) textView.setText(identifier); else { final int subaccount = confidentialData.getInt("subaccount", 0); final int pointer = confidentialData.getInt("pubkey_pointer"); textView.setText(ConfidentialAddress.fromP2SHHash( mService.getNetworkParameters(), Wally.hash160(mService.createOutScript(subaccount, pointer)), mService.getBlindingPubKey(subaccount, pointer) ).toString()); } textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { if (url == null) return; String domain = url; try { domain = new URI(url).getHost(); } catch (final URISyntaxException e) { e.printStackTrace(); } final String stripped = domain.startsWith("www.") ? domain.substring(4) : domain; UI.popup(TransactionActivity.this, R.string.warning, R.string.continueText, R.string.cancel) .content(getString(R.string.view_block_explorer, stripped)) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(final MaterialDialog dlg, final DialogAction which) { final String fullUrl = TextUtils.concat(url, identifier).toString(); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(fullUrl))); } }).build().show(); } }); }