Search in sources :

Example 81 with OnClickListener

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);
}
Also used : DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) Intent(android.content.Intent) File(java.io.File)

Example 82 with OnClickListener

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");
    }
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) HashMap(java.util.HashMap) Activity(android.app.Activity) OnClickListener(android.content.DialogInterface.OnClickListener) JSONObject(com.alibaba.fastjson.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 83 with OnClickListener

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;
}
Also used : AlertDialog(android.app.AlertDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ResolveInfo(android.content.pm.ResolveInfo) ListView(android.widget.ListView) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 84 with OnClickListener

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);
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) View(android.view.View)

Example 85 with OnClickListener

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();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Aggregations

OnClickListener (android.content.DialogInterface.OnClickListener)264 DialogInterface (android.content.DialogInterface)259 AlertDialog (android.app.AlertDialog)161 View (android.view.View)75 TextView (android.widget.TextView)52 Intent (android.content.Intent)44 SuppressLint (android.annotation.SuppressLint)41 Context (android.content.Context)35 AlertDialog (android.support.v7.app.AlertDialog)32 LayoutInflater (android.view.LayoutInflater)30 EditText (android.widget.EditText)30 Activity (android.app.Activity)27 Bundle (android.os.Bundle)25 OnCancelListener (android.content.DialogInterface.OnCancelListener)21 ImageView (android.widget.ImageView)17 Builder (android.app.AlertDialog.Builder)16 Dialog (android.app.Dialog)16 ProgressDialog (android.app.ProgressDialog)15 Paint (android.graphics.Paint)15 AdapterView (android.widget.AdapterView)15