List of usage examples for android.app AlertDialog setOnCancelListener
public void setOnCancelListener(@Nullable OnCancelListener listener)
From source file:com.hemou.android.account.AccountUtils.java
/** * Show conflict message about previously registered authenticator from * another application// www .j av a 2s .c o m * * @param activity */ private static void showConflictMessage(final Activity activity) { AlertDialog dialog = LightAlertDialog.create(activity); dialog.setTitle(activity.getString(string.authenticator_conflict_title)); dialog.setMessage(activity.getString(string.authenticator_conflict_message)); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { activity.finish(); } }); dialog.setButton(BUTTON_POSITIVE, activity.getString(android.R.string.ok), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.finish(); } }); dialog.show(); }
From source file:com.github.jthuraisamy.yellowusage.ui.InvalidNetworkDialog.java
@Override public void onResume() { super.onResume(); final AlertDialog alertDialog = (AlertDialog) getDialog(); // Set OnCancelListener. alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override//from w w w .jav a2 s .c o m public void onCancel(DialogInterface dialogInterface) { final MainActivity ctx = (MainActivity) getActivity(); ctx.finish(); } }); }
From source file:com.github.jthuraisamy.yellowusage.ui.VoiceOverageOutgoingCallWarningDialog.java
@Override public void onResume() { super.onResume(); final AlertDialog alertDialog = (AlertDialog) getDialog(); // Set OnCancelListener. alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override/*from w w w . ja v a2s . c om*/ public void onCancel(DialogInterface dialogInterface) { getActivity().finish(); } }); }
From source file:com.github.mobile.ui.DialogFragmentHelper.java
/** * Create default dialog/*from w ww .ja v a 2s.c o m*/ * * @return dialog */ protected AlertDialog createDialog() { final AlertDialog dialog = LightAlertDialog.create(getActivity()); dialog.setTitle(getTitle()); dialog.setMessage(getMessage()); dialog.setCancelable(true); dialog.setOnCancelListener(this); return dialog; }
From source file:net.granoeste.commons.ui.IconContextMenuDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final Bundle args = getArguments(); if (mTitle == null && args != null) { mTitle = args.getString(ICON_CONTEXT_MENU_TITLE); }/*from w w w .j a v a 2 s. c o m*/ if (args != null) { mMenuItems = (ArrayList<IconContextMenuItem>) args.getSerializable(ICON_CONTEXT_MENU_ITEMS); } if (mMenuAdapter == null) { if (mMenuItems != null) { mMenuAdapter = new IconMenuAdapter(getActivity()); for (final IconContextMenuItem iconContextMenuItem : mMenuItems) { mMenuAdapter.addItem(iconContextMenuItem); } } } if (!TextUtils.isEmpty(mTitle)) { builder.setTitle(mTitle); } builder.setAdapter(mMenuAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialoginterface, final int i) { final IconContextMenuItem item = (IconContextMenuItem) mMenuAdapter.getItem(i); mCallbacks.onIconContextMenuOnItemSelected(item); dismiss(); } }); builder.setInverseBackgroundForced(true); final AlertDialog dialog = builder.create(); dialog.setOnCancelListener(this); dialog.setOnDismissListener(this); return dialog; }
From source file:com.github.mobile.ui.ConfirmDialogFragment.java
public Dialog onCreateDialog(final Bundle savedInstanceState) { AlertDialog dialog = LightAlertDialog.create(getActivity()); dialog.setTitle(getTitle());/* ww w. j a v a2 s. c om*/ dialog.setMessage(getMessage()); dialog.setButton(BUTTON_POSITIVE, getResources().getString(android.R.string.yes), this); dialog.setButton(BUTTON_NEGATIVE, getResources().getString(android.R.string.no), this); dialog.setCancelable(true); dialog.setOnCancelListener(this); return dialog; }
From source file:org.pixmob.appengine.client.demo.DemoActivity.java
@Override protected Dialog onCreateDialog(int id) { if (NO_ACCOUNT_DIALOG == id) { final AlertDialog d = new AlertDialog.Builder(this).setTitle(R.string.error).setCancelable(false) .setMessage(R.string.no_account_error).setPositiveButton(R.string.quit, new OnClickListener() { @Override/*from w w w.ja v a 2s . co m*/ public void onClick(DialogInterface dialog, int which) { finish(); } }).create(); return d; } if (PROGRESS_DIALOG == id) { final ProgressDialog d = new ProgressDialog(this); d.setMessage(getString(R.string.connecting_to_appengine)); d.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { loginTask.cancel(true); // release resources when the task is canceled loginTask = null; } }); return d; } if (MODIFY_APPSPOT_BASE_DIALOG == id) { final EditText input = new EditText(this); input.setSelectAllOnFocus(true); input.setText(prefs.getString(APPSPOT_BASE_PREF, defaultAppspotBase)); final AlertDialog d = new AlertDialog.Builder(this).setView(input) .setTitle(R.string.enter_appspot_instance_name) .setPositiveButton(R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { appspotBase = trimToNull(input.getText().toString()); if (appspotBase == null) { appspotBase = defaultAppspotBase; } appspotBaseView.setText(appspotBase); storeFields(); } }).create(); return d; } return super.onCreateDialog(id); }
From source file:com.vk.sdk.VKCaptchaDialog.java
/** * Prepare, create and show dialog for displaying captcha *///from w ww . j a v a2 s. c om public void show() { Context context = VKUIHelper.getTopActivity(); View innerView = LayoutInflater.from(context).inflate(R.layout.dialog_vkcaptcha, null); assert innerView != null; mCaptchaAnswer = (EditText) innerView.findViewById(R.id.captchaAnswer); mCaptchaImage = (ImageView) innerView.findViewById(R.id.imageView); mProgressBar = (ProgressBar) innerView.findViewById(R.id.progressBar); mDensity = context.getResources().getDisplayMetrics().density; final AlertDialog dialog = new AlertDialog.Builder(context).setView(innerView).create(); mCaptchaAnswer.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); mCaptchaAnswer.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { if (actionId == EditorInfo.IME_ACTION_SEND) { sendAnswer(); return true; } return false; } }); dialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { sendAnswer(); } }); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { mCaptchaError.request.cancel(); } }); loadImage(); dialog.show(); }
From source file:com.renard.ocr.OCRActivity.java
private void askUserAboutDocumentLayout(final Pix pixOrg) { AlertDialog alertDialog = LayoutQuestionDialog.createDialog(this, new LayoutChoseListener() { @Override//from w ww.jav a 2s . c o m public void onLayoutChosen(final LayoutKind layoutKind, final String ocrLanguage) { if (layoutKind == LayoutKind.DO_NOTHING) { saveDocument(pixOrg, null, null, true); } else { getSupportActionBar().show(); getSupportActionBar().setDisplayShowTitleEnabled(true); // mFairyText.setText(R.string.progress_start); getSupportActionBar().setTitle(R.string.progress_start); if (layoutKind == LayoutKind.SIMPLE) { mOCR.startOCRForSimpleLayout(OCRActivity.this, ocrLanguage, pixOrg); } else if (layoutKind == LayoutKind.COMPLEX) { mOcrLanguage = ocrLanguage; mOCR.startLayoutAnalysis(pixOrg); } } } }); alertDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); alertDialog.show(); }
From source file:com.altcanvas.twitspeak.TwitSpeakActivity.java
public boolean checkStackTrace() { FileInputStream traceIn = null; try {/*from w w w . j a v a2 s . c o m*/ traceIn = openFileInput("stack.trace"); traceIn.close(); } catch (FileNotFoundException fnfe) { // No stack trace available return false; } catch (IOException ioe) { return false; } AlertDialog alert = new AlertDialog.Builder(this).create(); alert.setMessage(getResources().getString(R.string.crashreport_msg)); alert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.emailstr), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String trace = ""; String line = null; try { BufferedReader reader = new BufferedReader( new InputStreamReader(TwitSpeakActivity.this.openFileInput("stack.trace"))); while ((line = reader.readLine()) != null) { trace += line + "\n"; } } catch (FileNotFoundException fnfe) { Log.logException(TAG, fnfe); } catch (IOException ioe) { Log.logException(TAG, ioe); } Intent sendIntent = new Intent(Intent.ACTION_SEND); String subject = "Error report"; String body = getResources().getString(R.string.mailthisto_msg) + " jayesh@altcanvas.com: " + "\n\n" + G.getPhoneInfo() + "\n\n" + "TwitSpeak [" + G.VERSION_STRING + "]" + "\n\n" + trace + "\n\n"; sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "jayesh@altcanvas.com" }); sendIntent.putExtra(Intent.EXTRA_TEXT, body); sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.setType("message/rfc822"); TwitSpeakActivity.this.startActivityForResult( Intent.createChooser(sendIntent, getResources().getString(R.string.emailstr)), G.REQCODE_EMAIL_STACK_TRACE); TwitSpeakActivity.this.deleteFile("stack.trace"); } }); alert.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancelstr), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { TwitSpeakActivity.this.deleteFile("stack.trace"); TwitSpeakActivity.this.continueOnCreate(); } }); alert.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { TwitSpeakActivity.this.deleteFile("stack.trace"); TwitSpeakActivity.this.continueOnCreate(); } }); alert.show(); return true; }