Java Code Examples for com.afollestad.materialdialogs.DialogAction#NEGATIVE

The following examples show how to use com.afollestad.materialdialogs.DialogAction#NEGATIVE . 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: LogcatActivity.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
private void completePartialSelect() {

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    COMPLETE_PARTIAL_SELECT_REQUEST);
            return;
        }
        if (!SaveLogHelper.checkSdCard(this)) {
            cancelPartialSelect();
            return;
        }

        MaterialDialog.InputCallback onClickListener = (materialDialog, charSequence) -> {
            if (DialogHelper.isInvalidFilename(charSequence)) {
                cancelPartialSelect();
                Toast.makeText(LogcatActivity.this, R.string.enter_good_filename, Toast.LENGTH_SHORT).show();
            } else {
                String filename = charSequence.toString();
                if (partiallySelectedLogLines.size() == 2)
                    savePartialLog(filename, partiallySelectedLogLines.get(0), partiallySelectedLogLines.get(1));
            }
        };


        MaterialDialog.SingleButtonCallback onCancelListener = (dialog, which) -> {
            if(which == DialogAction.NEGATIVE) {
                cancelPartialSelect();
            }
        };

        DialogHelper.showFilenameSuggestingDialog(this, onCancelListener, onClickListener, R.string.save_log);

    }
 
Example 2
Source File: DonateDialog.java    From AcDisplay with GNU General Public License v2.0 5 votes vote down vote up
@NonNull
private MaterialDialog initDialog() {
    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity())
            .iconRes(R.drawable.ic_gift_white_24dp)
            .title(R.string.donate_dialog_title)
            .customView(R.layout.dialog_donate, false)
            .neutralText(R.string.close);

    final IConfiguration configuration = AppHeap.getInstance().getConfiguration();
    final boolean hasApl = configuration.getBilling().hasAlternativePaymentMethods();
    if (!hasApl) return builder.build();

    final Bitcoin btc = new Bitcoin();
    final PayPal pp = new PayPal();

    MaterialDialog.SingleButtonCallback callback = new MaterialDialog.SingleButtonCallback() {
        @Override
        public void onClick(@NonNull MaterialDialog materialDialog,
                            @NonNull DialogAction dialogAction) {
            if (dialogAction == DialogAction.POSITIVE) {
                startPaymentIntentWithWarningAlertDialog(CoinUtils.getPaymentIntent(btc));
            } else if (dialogAction == DialogAction.NEGATIVE) {
                startPaymentIntentWithWarningAlertDialog(CoinUtils.getPaymentIntent(pp));
            } else if (dialogAction == DialogAction.NEUTRAL) {
                dismiss();
            }
        }
    };
    return builder
            .positiveText(btc.getNameResource())
            .negativeText(pp.getNameResource())
            .onPositive(callback)
            .onNegative(callback)
            .onNeutral(callback)
            .autoDismiss(false)
            .build();
}
 
Example 3
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private void completePartialSelect() {

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    COMPLETE_PARTIAL_SELECT_REQUEST);
            return;
        }
        if (!SaveLogHelper.checkSdCard(this)) {
            cancelPartialSelect();
            return;
        }

        MaterialDialog.InputCallback onClickListener = new MaterialDialog.InputCallback() {

            @Override
            public void onInput(@NonNull MaterialDialog materialDialog, CharSequence charSequence) {
                if (DialogHelper.isInvalidFilename(charSequence)) {
                    cancelPartialSelect();
                    Toast.makeText(LogcatActivity.this, R.string.enter_good_filename, Toast.LENGTH_SHORT).show();
                } else {
                    String filename = charSequence.toString();
                    savePartialLog(filename, partiallySelectedLogLines.get(0), partiallySelectedLogLines.get(1));
                }
            }
        };


        MaterialDialog.SingleButtonCallback onCancelListener = new MaterialDialog.SingleButtonCallback() {
            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                if (which == DialogAction.NEGATIVE) {
                    cancelPartialSelect();
                }
            }
        };

        DialogHelper.showFilenameSuggestingDialog(this, onCancelListener, onClickListener, R.string.save_log);

    }
 
Example 4
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
private void completePartialSelect() {

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    COMPLETE_PARTIAL_SELECT_REQUEST);
            return;
        }
        if (!SaveLogHelper.checkSdCard(this)) {
            cancelPartialSelect();
            return;
        }

        MaterialDialog.InputCallback onClickListener = new MaterialDialog.InputCallback() {

            @Override
            public void onInput(@NonNull MaterialDialog materialDialog, CharSequence charSequence) {
                if (DialogHelper.isInvalidFilename(charSequence)) {
                    cancelPartialSelect();
                    Toast.makeText(LogcatActivity.this, R.string.enter_good_filename, Toast.LENGTH_SHORT).show();
                } else {
                    String filename = charSequence.toString();
                    savePartialLog(filename, partiallySelectedLogLines.get(0), partiallySelectedLogLines.get(1));
                }
            }
        };


        MaterialDialog.SingleButtonCallback onCancelListener = new MaterialDialog.SingleButtonCallback() {
            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                if (which == DialogAction.NEGATIVE) {
                    cancelPartialSelect();
                }
            }
        };

        DialogHelper.showFilenameSuggestingDialog(this, onCancelListener, onClickListener, R.string.save_log);

    }
 
Example 5
Source File: RecentFilesManager.java    From 920-text-editor-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
    if (which == DialogAction.NEGATIVE) {
        dbHelper.clearRecentFiles();
    }
}