use of android.content.DialogInterface.OnClickListener in project MGit by maks.
the class ImportRepositoryActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_create_external:
File dotGit = new File(getCurrentDir(), Repo.DOT_GIT_DIR);
if (dotGit.exists()) {
showToastMessage(R.string.alert_is_already_a_git_repo);
return true;
}
showMessageDialog(R.string.dialog_create_external_title, R.string.dialog_create_external_msg, R.string.dialog_create_external_positive_label, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
createExternalGitRepo();
}
});
return true;
case R.id.action_import_external:
Intent intent = new Intent();
intent.putExtra(RESULT_PATH, getCurrentDir().getAbsolutePath());
setResult(Activity.RESULT_OK, intent);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
use of android.content.DialogInterface.OnClickListener in project incubator-weex by apache.
the class WXModalUIModule method prompt.
@JSMethod(uiThread = true)
public void prompt(JSONObject jsObj, final JSCallback callback) {
if (mWXSDKInstance.getContext() instanceof Activity) {
String message = "";
String defaultValue = "";
String okTitle = OK;
String cancelTitle = CANCEL;
if (jsObj != null) {
try {
message = jsObj.getString(MESSAGE);
okTitle = jsObj.getString(OK_TITLE);
cancelTitle = jsObj.getString(CANCEL_TITLE);
defaultValue = jsObj.getString(DEFAULT);
} catch (Exception e) {
WXLogUtils.e("[WXModalUIModule] confirm param parse error ", e);
}
}
if (TextUtils.isEmpty(message)) {
message = "";
}
AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext());
builder.setMessage(message);
final EditText editText = new EditText(mWXSDKInstance.getContext());
editText.setText(defaultValue);
builder.setView(editText);
final String okTitleFinal = TextUtils.isEmpty(okTitle) ? OK : okTitle;
final String cancelTitleFinal = TextUtils.isEmpty(cancelTitle) ? CANCEL : cancelTitle;
builder.setPositiveButton(okTitleFinal, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (callback != null) {
Map<String, Object> result = new HashMap<String, Object>();
result.put(RESULT, okTitleFinal);
result.put(DATA, editText.getText().toString());
callback.invoke(result);
}
}
}).setNegativeButton(cancelTitleFinal, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (callback != null) {
Map<String, Object> result = new HashMap<String, Object>();
result.put(RESULT, cancelTitleFinal);
result.put(DATA, editText.getText().toString());
callback.invoke(result);
}
}
});
AlertDialog alertDialog = builder.create();
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show();
tracking(alertDialog);
} else {
WXLogUtils.e("when call prompt mWXSDKInstance.getContext() must instanceof Activity");
}
}
use of android.content.DialogInterface.OnClickListener in project android_packages_apps_DU-Tweaks by DirtyUnicorns.
the class IconPickerActivity method getIconPackDialog.
private Dialog getIconPackDialog(Context context) {
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View view = inflater.inflate(R.layout.dialog_iconpack, null);
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final IconPackageAdapter adapter = new IconPackageAdapter(this);
final ListView listView = (ListView) view.findViewById(R.id.iconpack_list);
final Dialog dialog;
adapter.load();
dialog = builder.setTitle(getString(R.string.icon_pack_picker_dialog_title)).setView(view).setOnCancelListener(this).setNegativeButton(android.R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onCancel(dialog);
}
}).create();
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ResolveInfo info = adapter.getItem(position);
String packageName = info.activityInfo.packageName;
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.dirtyunicorns.tweaks.IconPackGridActivity");
intent.putExtra("icon_package_name", packageName);
dialog.dismiss();
startActivityForResult(intent, ICON_PACK_ICON_RESULT);
}
});
return dialog;
}
use of android.content.DialogInterface.OnClickListener in project android_packages_apps_Settings by DirtyUnicorns.
the class ZenModeRuleSettingsBase method showDeleteRuleDialog.
private void showDeleteRuleDialog() {
final AlertDialog dialog = new AlertDialog.Builder(mContext).setMessage(getString(R.string.zen_mode_delete_rule_confirmation, mRule.getName())).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.zen_mode_delete_rule_button, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_ZEN_DELETE_RULE_OK);
mDeleting = true;
removeZenRule(mId);
}
}).show();
final View messageView = dialog.findViewById(android.R.id.message);
if (messageView != null) {
messageView.setTextDirection(View.TEXT_DIRECTION_LOCALE);
}
}
use of android.content.DialogInterface.OnClickListener in project android_packages_apps_Dialer by MoKee.
the class InCallActivity method showErrorDialog.
/**
* Utility function to bring up a generic "error" dialog.
*/
private void showErrorDialog(CharSequence msg) {
Log.i(this, "Show Dialog: " + msg);
dismissPendingDialogs();
mDialog = new AlertDialog.Builder(this).setMessage(msg).setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onDialogDismissed();
}
}).setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
onDialogDismissed();
}
}).create();
mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
mDialog.show();
}
Aggregations