Search in sources :

Example 31 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project xabber-android by redsolution.

the class ContactListActivity method onCreateDialog.

@Override
protected Dialog onCreateDialog(int id) {
    super.onCreateDialog(id);
    switch(id) {
        case DIALOG_CLOSE_APPLICATION_ID:
            ProgressDialog progressDialog = new ProgressDialog(this);
            progressDialog.setMessage(getString(R.string.application_state_closing));
            progressDialog.setOnCancelListener(new OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    finish();
                }
            });
            progressDialog.setIndeterminate(true);
            return progressDialog;
        default:
            return null;
    }
}
Also used : DialogInterface(android.content.DialogInterface) ProgressDialog(android.app.ProgressDialog) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 32 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project var3dframe by Var3D.

the class VAndroidLauncher method getTextInput.

public void getTextInput(final TextInputListener listener, final String title, final String text, final String hint) {
    final Context context = getContext();
    runOnUiThread(new Runnable() {

        public void run() {
            AlertDialog.Builder alert = new AlertDialog.Builder(context);
            alert.setTitle(title);
            final EditText input = new EditText(context);
            input.setHint(hint);
            input.setText(text);
            input.setSingleLine();
            alert.setView(input);
            alert.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    Gdx.app.postRunnable(new Runnable() {

                        @Override
                        public void run() {
                            listener.input(input.getText().toString());
                        }
                    });
                }
            });
            alert.setNegativeButton(context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    Gdx.app.postRunnable(new Runnable() {

                        @Override
                        public void run() {
                            listener.canceled();
                        }
                    });
                }
            });
            alert.setOnCancelListener(new OnCancelListener() {

                @Override
                public void onCancel(DialogInterface arg0) {
                    Gdx.app.postRunnable(new Runnable() {

                        @Override
                        public void run() {
                            listener.canceled();
                        }
                    });
                }
            });
            alert.show();
        }
    });
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 33 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project Inscription by MartinvanZ.

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 34 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project AndEngine by nicolasgramlich.

the class ActivityUtils method doAsync.

public static <T> void doAsync(final Context pContext, final CharSequence pTitle, final CharSequence pMessage, final Callable<T> pCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback, final boolean pCancelable) {
    new AsyncTask<Void, Void, T>() {

        private ProgressDialog mPD;

        private Exception mException = null;

        @Override
        public void onPreExecute() {
            this.mPD = ProgressDialog.show(pContext, pTitle, pMessage, true, pCancelable);
            if (pCancelable) {
                this.mPD.setOnCancelListener(new OnCancelListener() {

                    @Override
                    public void onCancel(final DialogInterface pDialogInterface) {
                        pExceptionCallback.onCallback(new CancelledException());
                        pDialogInterface.dismiss();
                    }
                });
            }
            super.onPreExecute();
        }

        @Override
        public T doInBackground(final Void... params) {
            try {
                return pCallable.call();
            } catch (final Exception e) {
                this.mException = e;
            }
            return null;
        }

        @Override
        public void onPostExecute(final T result) {
            try {
                this.mPD.dismiss();
            } catch (final Exception e) {
                Debug.e("Error", e);
            }
            if (this.isCancelled()) {
                this.mException = new CancelledException();
            }
            if (this.mException == null) {
                pCallback.onCallback(result);
            } else {
                if (pExceptionCallback == null) {
                    Debug.e("Error", this.mException);
                } else {
                    pExceptionCallback.onCallback(this.mException);
                }
            }
            super.onPostExecute(result);
        }
    }.execute((Void[]) null);
}
Also used : DialogInterface(android.content.DialogInterface) CancelledException(org.andengine.util.exception.CancelledException) ProgressDialog(android.app.ProgressDialog) CancelledException(org.andengine.util.exception.CancelledException) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 35 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project xabber-android by redsolution.

the class ContactList method onCreateDialog.

@Override
protected Dialog onCreateDialog(int id) {
    super.onCreateDialog(id);
    switch(id) {
        case DIALOG_CLOSE_APPLICATION_ID:
            ProgressDialog progressDialog = new ProgressDialog(this);
            progressDialog.setMessage(getString(R.string.application_state_closing));
            progressDialog.setOnCancelListener(new OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    finish();
                }
            });
            progressDialog.setIndeterminate(true);
            return progressDialog;
        default:
            return null;
    }
}
Also used : DialogInterface(android.content.DialogInterface) ProgressDialog(android.app.ProgressDialog) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Aggregations

OnCancelListener (android.content.DialogInterface.OnCancelListener)58 DialogInterface (android.content.DialogInterface)54 AlertDialog (android.app.AlertDialog)23 OnClickListener (android.content.DialogInterface.OnClickListener)18 View (android.view.View)13 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 LayoutInflater (android.view.LayoutInflater)5 InputMethodInfo (android.view.inputmethod.InputMethodInfo)5 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)5 CompoundButton (android.widget.CompoundButton)5