android.content.DialogInterface.OnClickListener Java Examples

The following examples show how to use android.content.DialogInterface.OnClickListener. 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: BrowserActivity.java    From EFRConnect-android with Apache License 2.0 6 votes vote down vote up
private void initLicenseDialog() {
    dialogLicense = new Dialog(this);
    dialogLicense.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialogLicense.setContentView(R.layout.dialog_about_silicon_labs_blue_gecko);
    WebView view = dialogLicense.findViewById(R.id.menu_item_license);
    Button closeButton = dialogLicense.findViewById(R.id.close_about_btn);

    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialogLicense.dismiss();
        }
    });

    view.loadUrl(ABOUT_DIALOG_HTML_ASSET_FILE_PATH);
}
 
Example #2
Source File: ChoiceDialog.java    From XQuickEnergy with Apache License 2.0 6 votes vote down vote up
private static AlertDialog getSendTypeDialog(Context c, CharSequence title)
{
 if(sendTypeDialog == null)
  sendTypeDialog = new AlertDialog.Builder(c)
   .setTitle(title)
   .setSingleChoiceItems(SendType.names, Config.sendType().ordinal(),
   new OnClickListener()
   {
    @Override
    public void onClick(DialogInterface p1, int p2)
    {
     Config.setSendType(p2);
    }
   })
   .setPositiveButton("OK", null)
   .create();
 return sendTypeDialog;
}
 
Example #3
Source File: ChoiceDialog.java    From XQuickEnergy with Apache License 2.0 6 votes vote down vote up
private static AlertDialog getRecallAnimalTypeDialog(Context c, CharSequence title)
{
 if(recallAnimalTypeDialog == null)
  recallAnimalTypeDialog = new AlertDialog.Builder(c)
   .setTitle(title)
   .setSingleChoiceItems(RecallAnimalType.names, Config.recallAnimalType().ordinal(),
   new OnClickListener()
   {
    @Override
    public void onClick(DialogInterface p1, int p2)
    {
     Config.setRecallAnimalType(p2);
    }
   })
   .setPositiveButton("OK", null)
   .create();
 return recallAnimalTypeDialog;
}
 
Example #4
Source File: TimePickerDialog.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void show() {
    super.show();
    getButton(BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mTimePicker.validateInput()) {
                TimePickerDialog.this.onClick(TimePickerDialog.this, BUTTON_POSITIVE);
                // Clearing focus forces the dialog to commit any pending
                // changes, e.g. typed text in a NumberPicker.
                mTimePicker.clearFocus();
                dismiss();
            }
        }
    });
}
 
Example #5
Source File: Dialogs.java    From EFRConnect-android with Apache License 2.0 6 votes vote down vote up
public static Dialog showAlert(CharSequence title, CharSequence message, Context context,
                               CharSequence positiveBtnText, CharSequence negativeBtnText, OnClickListener positiveListener,
                               OnClickListener negativeListener) {

    final AlertDialog alert = new AlertDialog.Builder(context).create();
    alert.setCancelable(false);
    alert.setCanceledOnTouchOutside(false);
    if (positiveListener != null && positiveBtnText != null) {
        alert.setButton(AlertDialog.BUTTON_POSITIVE, positiveBtnText, positiveListener);
    }
    if (negativeListener != null && negativeBtnText != null) {
        alert.setButton(AlertDialog.BUTTON_NEGATIVE, negativeBtnText, negativeListener);
    }
    alert.setTitle(title);
    alert.setMessage(message);
    alert.show();
    return alert;
}
 
Example #6
Source File: ConversationsListFragment.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
private void confirmDeleteThread(final String from) {
  	
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setTitle(R.string.confirm_dialog_title)
          .setIcon(android.R.drawable.ic_dialog_alert)
      .setCancelable(true)
      .setPositiveButton(R.string.delete, new OnClickListener() {
	@Override
	public void onClick(DialogInterface dialog, int which) {
		if(TextUtils.isEmpty(from)) {
		    getActivity().getContentResolver().delete(SipMessage.MESSAGE_URI, null, null);
		}else {
		    Builder threadUriBuilder = SipMessage.THREAD_ID_URI_BASE.buildUpon();
		    threadUriBuilder.appendEncodedPath(from);
		    getActivity().getContentResolver().delete(threadUriBuilder.build(), null, null);
		}
	}
})
      .setNegativeButton(R.string.no, null)
      .setMessage(TextUtils.isEmpty(from)
              ? R.string.confirm_delete_all_conversations
                      : R.string.confirm_delete_conversation)
      .show();
  }
 
Example #7
Source File: UIs.java    From letv with Apache License 2.0 6 votes vote down vote up
public static void callDialogMsgPositiveButton(Activity activity, String msgId, OnClickListener yes) {
    TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
    if (activity != null && dialogMsgByMsg != null) {
        CharSequence string;
        Builder builder = new Builder(activity);
        if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
            string = activity.getString(2131100003);
        } else {
            string = dialogMsgByMsg.title;
        }
        Dialog dialog = builder.setTitle(string).setIcon(2130837921).setMessage(dialogMsgByMsg.message).setPositiveButton(2131100002, yes).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #8
Source File: UIs.java    From letv with Apache License 2.0 6 votes vote down vote up
public static void callDialogMsgPosNeg(Activity activity, String msgId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
    TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
    if (activity != null && dialogMsgByMsg != null) {
        CharSequence string;
        Builder builder = new Builder(activity);
        if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
            string = activity.getString(2131100003);
        } else {
            string = dialogMsgByMsg.title;
        }
        Dialog dialog = builder.setTitle(string).setIcon(2130837921).setMessage(dialogMsgByMsg.message).setCancelable(false).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #9
Source File: UIUtils.java    From Android-FileBrowser-FilePicker with MIT License 6 votes vote down vote up
public static void showEditTextDialog(Context mContext, String title, String initialText, final IFuncPtr functionToBeRun) {

		LayoutInflater inflater = (LayoutInflater)mContext.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
		View v = inflater.inflate(R.layout.dialog_with_text, null);

		// custom dialog
		final Dialog dialog = new AlertDialog.Builder(mContext)
				.setTitle(title)
				.setView(v)
				.create();

		BootstrapButton okButton = (BootstrapButton) v.findViewById(R.id.okbutton);
		final BootstrapEditText insertedText = (BootstrapEditText) v.findViewById(R.id.addedText);
		insertedText.setText(initialText);
		okButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				functionToBeRun.execute(insertedText.getText().toString());
				dialog.dismiss();
			}
		});

		dialog.show();
	}
 
Example #10
Source File: UIUtils.java    From Android-FileBrowser-FilePicker with MIT License 6 votes vote down vote up
public static void ShowError(String msg, Context context)
{
	AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(context);                      
    dlgAlert.setMessage(msg);
    dlgAlert.setTitle(context.getString(R.string.error_common));
    dlgAlert.setIcon(android.R.drawable.ic_dialog_alert);
    dlgAlert.setPositiveButton(context.getString(R.string.ok), new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface popup, int arg1) {
			// TODO Auto-generated method stub
			popup.dismiss();
		}
	});
    dlgAlert.setCancelable(false);
    dlgAlert.show();
}
 
Example #11
Source File: UIsUtils.java    From letv with Apache License 2.0 6 votes vote down vote up
public static void callDialogMsgPosNeg(Activity activity, String msgId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
    TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
    if (activity != null && dialogMsgByMsg != null) {
        CharSequence string;
        Builder builder = new Builder(activity);
        if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
            string = activity.getString(R.string.dialog_default_title);
        } else {
            string = dialogMsgByMsg.title;
        }
        Dialog dialog = builder.setTitle(string).setIcon(R.drawable.dialog_icon).setMessage(dialogMsgByMsg.message).setCancelable(false).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #12
Source File: UIUtils.java    From Android-FileBrowser-FilePicker with MIT License 6 votes vote down vote up
public static void ShowMsg(String msg, String title,Context context)
{
	AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(context);                      
    dlgAlert.setMessage(msg);
    dlgAlert.setTitle(title);
    dlgAlert.setIcon(android.R.drawable.ic_dialog_info);
    dlgAlert.setPositiveButton(context.getString(R.string.ok), new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface popup, int arg1) {
			// TODO Auto-generated method stub
			popup.dismiss();
		}
	});
    dlgAlert.setCancelable(false);
    dlgAlert.show();
}
 
Example #13
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, String message, OnClickListener yes, boolean cancelable) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(message).setPositiveButton(R.string.dialog_default_ok, yes).create();
        dialog.setCancelable(cancelable);
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #14
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, int messageId, OnClickListener yes, OnClickListener no) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(messageId).setPositiveButton(R.string.dialog_default_ok, yes).setNegativeButton(R.string.dialog_default_no, no).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
 
Example #15
Source File: UIs.java    From letv with Apache License 2.0 5 votes vote down vote up
public static boolean call(Activity activity, int messageId, int yes, int no, OnClickListener yesListener, OnClickListener noListener, View view, boolean cancelable) {
    if (activity == null) {
        return false;
    }
    Dialog dialog = new Builder(activity).setTitle(2131100003).setIcon(2130837921).setMessage(messageId).setCancelable(cancelable).setView(view).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
    if (activity.isFinishing() || activity.isRestricted()) {
        return false;
    }
    try {
        dialog.show();
    } catch (Exception e) {
    }
    return true;
}
 
Example #16
Source File: UIsUtils.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, String message, OnClickListener yes) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(message).setPositiveButton(R.string.dialog_default_ok, yes).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #17
Source File: UIs.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, String message, OnClickListener yes) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(2131100003).setIcon(2130837921).setMessage(message).setPositiveButton(2131100002, yes).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #18
Source File: UIs.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, int messageId, OnClickListener yes) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(2131100003).setIcon(2130837921).setMessage(messageId).setPositiveButton(2131100002, yes).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #19
Source File: UIs.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, int titleId, int messageId, OnClickListener yes, OnClickListener no) {
    if (activity != null) {
        try {
            Dialog dialog = new Builder(activity).setTitle(titleId).setIcon(2130837921).setMessage(messageId).setPositiveButton(2131100002, yes).setNegativeButton(2131100001, no).create();
            if (!activity.isFinishing() && !activity.isRestricted()) {
                try {
                    dialog.show();
                } catch (Exception e) {
                }
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }
}
 
Example #20
Source File: UIs.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, String message, OnClickListener yes, boolean cancelable) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(2131100003).setIcon(2130837921).setMessage(message).setPositiveButton(2131100002, yes).create();
        dialog.setCancelable(cancelable);
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #21
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, String message, OnClickListener yes) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(message).setPositiveButton(R.string.dialog_default_ok, yes).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #22
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, int title, int messageId, int yes, OnClickListener yesListener, boolean cancelable) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(title).setIcon(R.drawable.dialog_icon).setMessage(messageId).setCancelable(cancelable).setPositiveButton(yes, yesListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #23
Source File: CreateFileFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());

    final View view = dialogInflater.inflate(R.layout.dialog_create_dir, null, false);
    final EditText text1 = (EditText) view.findViewById(android.R.id.text1);
    Utils.tintWidget(text1);

    String title = getArguments().getString(EXTRA_DISPLAY_NAME);
    if(!TextUtils.isEmpty(title)) {
        text1.setText(title);
        text1.setSelection(title.length());
    }
    builder.setTitle(R.string.menu_create_file);
    builder.setView(view);

    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String displayName = text1.getText().toString();
            final String mimeType = getArguments().getString(EXTRA_MIME_TYPE);
            String extension = FileUtils.getExtFromFilename(displayName);
            final DocumentsActivity activity = (DocumentsActivity) getActivity();
            final DocumentInfo cwd = activity.getCurrentDirectory();
            new CreateFileTask(activity, cwd,
                    TextUtils.isEmpty(extension) ? mimeType : extension, displayName).executeOnExecutor(
                    ProviderExecutor.forAuthority(cwd.authority));
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
}
 
Example #24
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, int titleId, int messageId, OnClickListener yes, OnClickListener no) {
    if (activity != null) {
        try {
            Dialog dialog = new Builder(activity).setTitle(titleId).setIcon(R.drawable.dialog_icon).setMessage(messageId).setPositiveButton(R.string.dialog_default_ok, yes).setNegativeButton(R.string.dialog_default_no, no).create();
            if (!activity.isFinishing() && !activity.isRestricted()) {
                try {
                    dialog.show();
                } catch (Exception e) {
                }
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }
}
 
Example #25
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Context activity, String title, String message, int yes, int no, OnClickListener yesListener, OnClickListener noListener, boolean cancelable) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(title).setIcon(R.drawable.dialog_icon).setMessage(message).setCancelable(cancelable).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if ((activity instanceof Activity) && !((Activity) activity).isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #26
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static boolean call(Activity activity, int messageId, int yes, int no, OnClickListener yesListener, OnClickListener noListener, View view, boolean cancelable) {
    if (activity == null) {
        return false;
    }
    Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(messageId).setCancelable(cancelable).setView(view).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
    if (activity.isFinishing() || activity.isRestricted()) {
        return false;
    }
    try {
        dialog.show();
    } catch (Exception e) {
    }
    return true;
}
 
Example #27
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, int messageId, int yes, int no, OnClickListener yesListener, OnClickListener noListener, View view) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(messageId).setView(view).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #28
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, int messageId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(messageId).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #29
Source File: DialogUtil.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void call(Activity activity, String messageId, int yesId, int noId, OnClickListener yes, OnClickListener no) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setIcon(R.drawable.dialog_icon).setMessage(messageId).setPositiveButton(yesId, yes).setNegativeButton(noId, no).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            dialog.show();
        }
    }
}
 
Example #30
Source File: ErrorDialogFragments.java    From KUtils with Apache License 2.0 5 votes vote down vote up
public static Dialog createDialog(Context context, Bundle arguments, OnClickListener onClickListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(arguments.getString(ErrorDialogManager.KEY_TITLE));
    builder.setMessage(arguments.getString(ErrorDialogManager.KEY_MESSAGE));
    if (ERROR_DIALOG_ICON != 0) {
        builder.setIcon(ERROR_DIALOG_ICON);
    }
    builder.setPositiveButton(android.R.string.ok, onClickListener);
    return builder.create();
}