Search in sources :

Example 1 with ResourceMessageException

use of com.github.ignition.core.exceptions.ResourceMessageException in project ignition by mttkay.

the class IgnitedDialogs method newErrorDialog.

public static AlertDialog.Builder newErrorDialog(final Activity activity, String title, Exception error) {
    String screenMessage = "";
    if (error instanceof ResourceMessageException) {
        screenMessage = activity.getString(((ResourceMessageException) error).getClientMessageResourceId());
    } else {
        screenMessage = error.getLocalizedMessage();
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(title);
    builder.setMessage(screenMessage);
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setCancelable(false);
    builder.setPositiveButton(activity.getString(android.R.string.ok), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    return builder;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder) OnClickListener(android.content.DialogInterface.OnClickListener) ResourceMessageException(com.github.ignition.core.exceptions.ResourceMessageException)

Aggregations

AlertDialog (android.app.AlertDialog)1 Builder (android.app.AlertDialog.Builder)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 ResourceMessageException (com.github.ignition.core.exceptions.ResourceMessageException)1