Example usage for android.app AlertDialog dismiss

List of usage examples for android.app AlertDialog dismiss

Introduction

In this page you can find the example usage for android.app AlertDialog dismiss.

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:de.petermoesenthin.alarming.fragments.SetAlarmFragment.java

private void showAlarmMessageDialog(final AlarmCardRecyclerAdapter.AlarmCardViewHolder viewHolder,
        final int position) {
    Log.d(DEBUG_TAG, "Showing alarm message dialog");
    LDialogView dialogView = new LDialogView(mContext, R.layout.dialog_content_edit_text,
            R.string.dialog_title_set_alarm_message);
    LDialog alarmMessageDialog = new LDialog(mContext, dialogView);
    final EditText editText = (EditText) dialogView.getView().findViewById(R.id.editText);
    editText.setInputType(InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
    String prefText = mAlarmPrefs.get(position).getMessage();
    editText.setText(prefText);// w w w.jav  a  2s .c om
    alarmMessageDialog.setPositiveButtonListener(new LClickListener() {
        @Override
        public void onClick(AlertDialog dialog1) {
            String text = editText.getText().toString();
            mAlarmPrefs.get(position).setMessage(text);
            viewHolder.alarmText.setText(text);
            PrefUtil.setAlarms(mContext, mAlarmPrefs);
            dialog1.dismiss();
        }
    });
    alarmMessageDialog.setNegativeButtonListener(new LClickListener() {
        @Override
        public void onClick(AlertDialog dialog) {
            dialog.dismiss();
        }
    });
    alarmMessageDialog.show();
}

From source file:github.daneren2005.dsub.util.Util.java

private static void showDialog(Context context, int icon, String title, String message, boolean linkify) {
    SpannableString ss = new SpannableString(message);
    if (linkify) {
        Linkify.addLinks(ss, Linkify.ALL);
    }//from   www.j  a v  a 2s  . com

    AlertDialog dialog = new AlertDialog.Builder(context).setIcon(icon).setTitle(title).setMessage(ss)
            .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int i) {
                    dialog.dismiss();
                }
            }).show();

    ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // exit the app
    case R.id.exit:
        Toast.makeText(this, "Closing...", Toast.LENGTH_SHORT).show();
        //System.exit(0);
        this.finish();
        break;/*from  w w  w .  j a  v  a 2 s.  c om*/
    // show the FAQ 
    case R.id.help:
        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("FAQ");
        dialog.setMessage(Constants.FAQ);
        dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog.show();
        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20);
        break;
    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}

From source file:org.kaaproject.kaa.examples.robotrun.android.RobotRunFragment.java

private void showError(String message) {
    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setMessage(message).setTitle("Error")
            .setNeutralButton("Close", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int which) {
                    dialog.dismiss();
                }//  w w w.j  av a 2  s . com
            }).create();
    dialog.show();
}

From source file:es.uja.photofirma.android.SignUpActivity.java

/**
 * Advertencia a cerca de la privacidad del usuario, el usuario ser notificado
 * //from  ww w .j  a  v a  2s. c  o m
 */
public void onTermsOfUse(View view) {
    final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Terminos de uso");
    alertDialog.setMessage(getString(R.string.terms_of_use));
    alertDialog.setCancelable(false);
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
        }
    });
    alertDialog.show();

}

From source file:de.petermoesenthin.alarming.fragments.SetAlarmFragment.java

private void showColorPickerDialog(final AlarmCardRecyclerAdapter.AlarmCardViewHolder viewHolder,
        final int position) {
    LDialogView dialogView = new LDialogView(mContext, R.layout.dialog_content_color_picker,
            R.string.dialog_title_set_alarm_color);
    final LDialog colorPickerDialog = new LDialog(mContext, dialogView);
    final ColorPicker cp = (ColorPicker) dialogView.getView().findViewById(R.id.dialog_color_picker);
    final SVBar svBar = (SVBar) dialogView.getView().findViewById(R.id.colorDialog_svBar);
    cp.addSVBar(svBar);/*w w w  .  j av a  2  s.  c o m*/
    final AlarmPref alarm = mAlarmPrefs.get(position);
    int color = alarm.getColor();
    if (color == -1) {
        color = getResources().getColor(R.color.material_yellow);
    }
    cp.setOldCenterColor(color);

    colorPickerDialog.setPositiveButtonListener(new LClickListener() {
        @Override
        public void onClick(AlertDialog dialog) {
            int colorChoice = cp.getColor();
            alarm.setColor(colorChoice);
            View v = viewHolder.chooseColor.findViewById(R.id.view_color_indicator);
            v.setBackgroundColor(colorChoice);
            PrefUtil.setAlarms(mContext, mAlarmPrefs);
            dialog.dismiss();
        }
    });
    colorPickerDialog.setNegativeButtonListener(new LClickListener() {
        @Override
        public void onClick(AlertDialog dialog) {
            dialog.dismiss();
        }
    });
    colorPickerDialog.show();
}

From source file:com.jwork.dhammapada.MainActivity.java

private void showCrashDialog() {
    final CrashHandler handler = CrashHandler.getInstance();
    final AlertDialog ad = new AlertDialog.Builder(this).create();
    ad.setTitle("Error Report");
    ad.setMessage("An error was detected. Reporting it will support faster bug fixing.");
    ad.setButton(AlertDialog.BUTTON_POSITIVE, "Report it", new DialogInterface.OnClickListener() {

        @Override/*from w  w w. ja va 2  s.c o  m*/
        public void onClick(DialogInterface dialog, int which) {
            handler.clearCrashFlag();
            ad.dismiss();
            MainActivity.this.finish();
            handler.sendEmail(MainActivity.this);
            //            MainActivity.this.startActivity(new Intent(MainActivity.this, MainActivity.class));
        }
    });
    ad.setButton(AlertDialog.BUTTON_NEGATIVE, "Not now", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            handler.clearCrashFlag();
            ad.dismiss();
            MainActivity.this.finish();
            MainActivity.this.startActivity(new Intent(MainActivity.this, MainActivity.class));
        }
    });
    ad.show();
}

From source file:com.aniruddhc.acemusic.player.WelcomeActivity.WelcomeActivity.java

/**
 * Asks the user to install the GMusic app.
 *///from w w w .  j a  v a 2 s. co m
private void promptUserInstallGooglePlayMusic() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    AlertDialog dialog;
    builder.setTitle(R.string.google_play_music_no_asterisk);
    builder.setMessage(R.string.prompt_user_install_google_play_music);
    builder.setPositiveButton(R.string.yes, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://details?id=com.google.android.music"));
            startActivity(intent);

        }

    });

    builder.setNegativeButton(R.string.no, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mApp.getSharedPreferences().edit().putBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false).commit();
            Toast.makeText(mContext, R.string.google_play_music_disabled, Toast.LENGTH_LONG).show();
            dialog.dismiss();

        }

    });

    dialog = builder.create();
    dialog.show();
}

From source file:github.daneren2005.dsub.util.Util.java

public static void showHTMLDialog(Context context, int title, int message) {
    AlertDialog dialog = new AlertDialog.Builder(context).setIcon(android.R.drawable.ic_dialog_info)
            .setTitle(title).setMessage(Html.fromHtml(context.getResources().getString(message)))
            .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
                @Override/*w ww. j a va  2s.  c  o m*/
                public void onClick(DialogInterface dialog, int i) {
                    dialog.dismiss();
                }
            }).show();
}

From source file:com.keylesspalace.tusky.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("lightTheme", false)) {
        setTheme(R.style.AppTheme_Light);
    }/*from w w w  .  j a va2s.c  o m*/

    setContentView(R.layout.activity_login);
    ButterKnife.bind(this);

    if (savedInstanceState != null) {
        domain = savedInstanceState.getString("domain");
        clientId = savedInstanceState.getString("clientId");
        clientSecret = savedInstanceState.getString("clientSecret");
    } else {
        domain = null;
        clientId = null;
        clientSecret = null;
    }

    preferences = getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onButtonClick(editText);
        }
    });

    final Context context = this;

    whatsAnInstance.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(context).setMessage(R.string.dialog_whats_an_instance)
                    .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    }).show();
            TextView textView = (TextView) dialog.findViewById(android.R.id.message);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        }
    });
}