Search in sources :

Example 46 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project Etar-Calendar by Etar-Group.

the class EditEventFragment method displayEditWhichDialog.

protected void displayEditWhichDialog() {
    if (mModification == Utils.MODIFY_UNINITIALIZED) {
        final boolean notSynced = TextUtils.isEmpty(mModel.mSyncId);
        boolean isFirstEventInSeries = mModel.mIsFirstEventInSeries;
        int itemIndex = 0;
        CharSequence[] items;
        if (notSynced) {
            // or changing a single instance.
            if (isFirstEventInSeries) {
                // Still display the option so the user knows all events are
                // changing
                items = new CharSequence[1];
            } else {
                items = new CharSequence[2];
            }
        } else {
            if (isFirstEventInSeries) {
                items = new CharSequence[2];
            } else {
                items = new CharSequence[3];
            }
            items[itemIndex++] = mActivity.getText(R.string.modify_event);
        }
        items[itemIndex++] = mActivity.getText(R.string.modify_all);
        // Do one more check to make sure this remains at the end of the list
        if (!isFirstEventInSeries) {
            items[itemIndex++] = mActivity.getText(R.string.modify_all_following);
        }
        // Display the modification dialog.
        if (mModifyDialog != null) {
            mModifyDialog.dismiss();
            mModifyDialog = null;
        }
        mModifyDialog = new AlertDialog.Builder(mActivity).setTitle(R.string.edit_event_label).setItems(items, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (which == 0) {
                    // Update this if we start allowing exceptions
                    // to unsynced events in the app
                    mModification = notSynced ? Utils.MODIFY_ALL : Utils.MODIFY_SELECTED;
                    if (mModification == Utils.MODIFY_SELECTED) {
                        mModel.mOriginalSyncId = notSynced ? null : mModel.mSyncId;
                        mModel.mOriginalId = mModel.mId;
                    }
                } else if (which == 1) {
                    mModification = notSynced ? Utils.MODIFY_ALL_FOLLOWING : Utils.MODIFY_ALL;
                } else if (which == 2) {
                    mModification = Utils.MODIFY_ALL_FOLLOWING;
                }
                mView.setModification(mModification);
            }
        }).show();
        mModifyDialog.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                Activity a = EditEventFragment.this.getActivity();
                if (a != null) {
                    a.finish();
                }
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) Activity(android.app.Activity) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 47 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project 9GAG by Mixiaoxiao.

the class MxxDialogUtil method creatConfirmDialog.

public static Dialog creatConfirmDialog(Context context, CharSequence title, CharSequence message, CharSequence btn_right_text, CharSequence btn_left_text, boolean canceledOnTouchOutside, boolean cancelable, final MxxDialogListener mxxDialogListener) {
    final Dialog dialog = new Dialog(context, R.style.mxx_theme_dialog);
    TextView mMessageView = null;
    TextView mTitleView = null;
    View view = LayoutInflater.from(context).inflate(R.layout.mxx_dialog_confirm_layout, null);
    mTitleView = (TextView) view.findViewById(R.id.mxx_dialog_confirm_title);
    mTitleView.setText(title);
    mMessageView = (TextView) view.findViewById(R.id.mxx_dialog_confirm_message);
    if (message != null) {
        mMessageView.setText(message);
    } else {
        mMessageView.setVisibility(View.GONE);
    }
    TextView btn1 = (TextView) view.findViewById(R.id.mxx_dialog_confirm_btn1);
    btn1.setText(btn_right_text);
    btn1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            dialog.dismiss();
            if (mxxDialogListener != null) {
                mxxDialogListener.onRightBtnClick();
            }
        }
    });
    if (btn_left_text != null) {
        TextView btn2 = (TextView) view.findViewById(R.id.mxx_dialog_confirm_btn2);
        btn2.setText(btn_left_text);
        btn2.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                dialog.dismiss();
                if (mxxDialogListener != null) {
                    mxxDialogListener.onLeftBtnClick();
                }
            }
        });
    } else {
        view.findViewById(R.id.mxx_dialog_confirm_btn2).setVisibility(View.GONE);
        view.findViewById(R.id.mxx_dialog_btns_divider).setVisibility(View.GONE);
    }
    dialog.setCanceledOnTouchOutside(canceledOnTouchOutside);
    dialog.setContentView(view);
    dialog.setCancelable(cancelable);
    dialog.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            // TODO Auto-generated method stub
            if (mxxDialogListener != null) {
                mxxDialogListener.onCancel();
            }
        }
    });
    // dialog.show();
    return dialog;
}
Also used : DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 48 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project SmartCampus by Vegen.

the class EaseBaiduMapActivity method showMapWithLocationClient.

private void showMapWithLocationClient() {
    String str1 = getResources().getString(R.string.Making_sure_your_location);
    progressDialog = new ProgressDialog(this);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setMessage(str1);
    progressDialog.setOnCancelListener(new OnCancelListener() {

        public void onCancel(DialogInterface arg0) {
            if (progressDialog.isShowing()) {
                progressDialog.dismiss();
            }
            Log.d("map", "cancel retrieve location");
            finish();
        }
    });
    progressDialog.show();
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    // open gps
    option.setOpenGps(true);
    // option.setCoorType("bd09ll");
    // Johnson change to use gcj02 coordination. chinese national standard
    // so need to conver to bd09 everytime when draw on baidu map
    option.setCoorType("gcj02");
    option.setScanSpan(30000);
    option.setAddrType("all");
    mLocClient.setLocOption(option);
}
Also used : LocationClient(com.baidu.location.LocationClient) DialogInterface(android.content.DialogInterface) LocationClientOption(com.baidu.location.LocationClientOption) ProgressDialog(android.app.ProgressDialog) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 49 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project Klyph by jonathangerbaud.

the class ChangeLogDialog method show.

protected void show(final int version) {
    // Get resources
    final String packageName = mContext.getPackageName();
    final Resources resources;
    try {
        resources = mContext.getPackageManager().getResourcesForApplication(packageName);
    } catch (NameNotFoundException ignored) {
        return;
    }
    // Get dialog title
    String title = resources.getString(R.string.title_changelog);
    title = String.format("%s v%s", title, getAppVersion());
    // Create html change log
    final String htmlChangelog = getHTMLChangelog(R.xml.changelog, resources, version);
    // Get button strings
    final String closeString = resources.getString(R.string.changelog_close);
    // Check for empty change log
    if (htmlChangelog.length() == 0) {
        // It seems like there is nothing to show, just bail out.
        return;
    }
    // Create web view and load html
    final WebView webView = new WebView(mContext);
    webView.loadDataWithBaseURL(null, htmlChangelog, "text/html", "utf-8", null);
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext).setTitle(title).setView(webView).setPositiveButton(closeString, new Dialog.OnClickListener() {

        public void onClick(final DialogInterface dialogInterface, final int i) {
            dialogInterface.dismiss();
        }
    }).setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
        }
    });
    AlertDialog dialog = builder.create();
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(final DialogInterface dialog) {
            if (mOnDismissListener != null) {
                mOnDismissListener.onDismiss(dialog);
            }
        }
    });
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) DialogInterface(android.content.DialogInterface) Resources(android.content.res.Resources) WebView(android.webkit.WebView) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 50 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project Android-DialogFragments by wada811.

the class AbstractDialogFragment method setOnCancelListener.

protected void setOnCancelListener(Dialog dialog) {
    useOnCancelListener = true;
    dialog.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            bindCancelListener();
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Aggregations

OnCancelListener (android.content.DialogInterface.OnCancelListener)60 DialogInterface (android.content.DialogInterface)56 AlertDialog (android.app.AlertDialog)24 OnClickListener (android.content.DialogInterface.OnClickListener)18 View (android.view.View)14 Context (android.content.Context)12 ProgressDialog (android.app.ProgressDialog)11 TextView (android.widget.TextView)11 Intent (android.content.Intent)10 OnDismissListener (android.content.DialogInterface.OnDismissListener)7 Dialog (android.app.Dialog)6 SharedPreferences (android.content.SharedPreferences)6 TypedArray (android.content.res.TypedArray)6 ArrayList (java.util.ArrayList)6 Drawable (android.graphics.drawable.Drawable)5 LocaleList (android.os.LocaleList)5 NonNull (android.support.annotation.NonNull)5 LayoutInflater (android.view.LayoutInflater)5 InputMethodInfo (android.view.inputmethod.InputMethodInfo)5 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)5