Java Code Examples for android.support.v7.app.AlertDialog.Builder#show()

The following examples show how to use android.support.v7.app.AlertDialog.Builder#show() . 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: DialogFactory.java    From QuickNote with Apache License 2.0 5 votes vote down vote up
public static void createAndShowDialog(Context context, String title, String content,
                                       String negativeButtonTip, DialogInterface.OnClickListener negativeListener,
                                       String positiveButtonTip, DialogInterface.OnClickListener positiveListener) {
    Builder builder = new Builder(context);
    builder.setTitle(title);
    builder.setMessage(content);
    builder.setNegativeButton(negativeButtonTip, negativeListener);
    builder.setPositiveButton(positiveButtonTip, positiveListener);
    builder.show();
}
 
Example 2
Source File: DialogFactory.java    From QuickNote with Apache License 2.0 5 votes vote down vote up
public static EditText showInputDialog(Context context, String title, String content, DialogInterface.OnClickListener positiveListener) {
    Builder builder = new Builder(context);
    builder.setTitle(title);
    builder.setMessage(content);
    AppCompatEditText input = new AppCompatEditText(context);
    builder.setView(input, PADDING, PADDING, PADDING, PADDING);
    builder.setNegativeButton(CANCEL_TIP, null);
    builder.setPositiveButton(SURE_TIP, positiveListener);
    builder.show();
    return input;
}
 
Example 3
Source File: DialogFactory.java    From QuickNote with Apache License 2.0 5 votes vote down vote up
public static void showInputDialog(Context context, String title, View contentView, DialogInterface.OnClickListener positiveListener) {
    Builder builder = new Builder(context);
    builder.setTitle(title);
    builder.setMessage(null);
    builder.setView(contentView, 3 * PADDING, PADDING, 3 * PADDING, PADDING);
    builder.setNegativeButton(QuickNote.getString(R.string.popup_window_cancel), null);
    builder.setPositiveButton(QuickNote.getString(R.string.popup_window_sure), positiveListener);
    builder.show();
}
 
Example 4
Source File: PermissionsFragment.java    From spark-setup-android with Apache License 2.0 5 votes vote down vote up
public void ensurePermission(final @NonNull String permission) {
    Builder dialogBuilder = new AlertDialog.Builder(getActivity())
            .setCancelable(false);

    // FIXME: stop referring to these location permission-specific strings here,
    // try to retrieve them from the client
    if (ActivityCompat.checkSelfPermission(getActivity(), permission) != PERMISSION_GRANTED ||
            ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), permission)) {
        dialogBuilder.setTitle(R.string.location_permission_dialog_title)
                .setMessage(R.string.location_permission_dialog_text)
                .setPositiveButton(R.string.got_it, (dialog, which) -> {
                    dialog.dismiss();
                    requestPermission(permission);
                });
    } else {
        // user has explicitly denied this permission to setup.
        // show a simple dialog and bail out.
        dialogBuilder.setTitle(R.string.location_permission_denied_dialog_title)
                .setMessage(R.string.location_permission_denied_dialog_text)
                .setPositiveButton(R.string.settings, (dialog, which) -> {
                    dialog.dismiss();
                    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    String pkgName = getActivity().getApplicationInfo().packageName;
                    intent.setData(Uri.parse("package:" + pkgName));
                    startActivity(intent);
                })
                .setNegativeButton(R.string.exit_setup, (dialog, which) -> {
                    Client client = (Client) getActivity();
                    client.onUserDeniedPermission(permission);
                });
    }

    dialogBuilder.show();
}