Java Code Examples for android.content.DialogInterface#OnDismissListener

The following examples show how to use android.content.DialogInterface#OnDismissListener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityUtils.java    From memetastic with GNU General Public License v3.0 6 votes vote down vote up
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) {
    ScrollView scroll = new ScrollView(_context);
    AppCompatTextView textView = new AppCompatTextView(_context);
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics());

    scroll.setPadding(padding, 0, padding, 0);
    scroll.addView(textView);
    textView.setMovementMethod(new LinkMovementMethod());
    textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);

    AlertDialog.Builder dialog = new AlertDialog.Builder(_context)
            .setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener)
            .setView(scroll);
    if (resTitleId != 0) {
        dialog.setTitle(resTitleId);
    }
    dialogFullWidth(dialog.show(), true, false);
}
 
Example 2
Source File: PermissionActivity.java    From permissionUtil with Apache License 2.0 5 votes vote down vote up
private void showRationale(DialogInterface.OnDismissListener listener) {
    PermissionCallback callback = PermissionUtil.getCallback();
    String title = getCallbackTitle(callback);
    String message = getCallbackMessage(callback);
    AlertDialog dialog = new AlertDialog.Builder(this,R.style.Theme_AppCompat_Light_Dialog_MinWidth)
            .setTitle(title)
            .setMessage(message)
            .setPositiveButton(android.R.string.ok, null)
            .setOnDismissListener(listener)
            .create();
    dialog.show();
}
 
Example 3
Source File: Dialog.java    From SmartFlasher with GNU General Public License v3.0 5 votes vote down vote up
public Dialog setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
    mOnDismissListener = onDismissListener;
    setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            if (mOnDismissListener != null) {
                mOnDismissListener.onDismiss(dialogInterface);
            }
        }
    });
    return this;
}
 
Example 4
Source File: MyAppInstallDialog.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
public static MyAppInstallDialog newInstance(String appName, DialogInterface.OnClickListener okListener, DialogInterface.OnDismissListener dismissListener) {
    MyAppInstallDialog dialog = new MyAppInstallDialog();
    dialog.appName = appName;
    dialog.okListener = okListener;
    dialog.dismissListener = dismissListener;
    return dialog;
}
 
Example 5
Source File: ViewUtils.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
public static Dialog dialogBuilder(CharSequence message, DialogInterface.OnClickListener negativeListener,
                                   DialogInterface.OnClickListener positiveListener,
                                   DialogInterface.OnDismissListener dismissListener, Context context) {
    Dialog dialog = new Dialog(context).setMessage(message);
    if (negativeListener != null) {
        dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener);
    }
    if (positiveListener != null) {
        dialog.setPositiveButton(context.getString(R.string.ok), positiveListener);
    }
    if (dismissListener != null) {
        dialog.setOnDismissListener(dismissListener);
    }
    return dialog;
}
 
Example 6
Source File: BaseDialog.java    From AndroidProject with Apache License 2.0 5 votes vote down vote up
/**
 * 设置一个销毁监听器
 *
 * @param listener       销毁监听器对象
 * @deprecated           请使用 {@link #addOnDismissListener(BaseDialog.OnDismissListener)}
 */
@Deprecated
@Override
public void setOnDismissListener(@Nullable DialogInterface.OnDismissListener listener) {
    if (listener == null) {
        return;
    }
    addOnDismissListener(new DismissListenerWrapper(listener));
}
 
Example 7
Source File: DialogUtils.java    From android-md-core with Apache License 2.0 5 votes vote down vote up
public static AlertDialog showInfoDialog(Context context, CharSequence message, DialogInterface.OnClickListener onClickListener,
    DialogInterface.OnDismissListener onDismissListener) {
  AlertDialog alertDialog = new AlertDialog.Builder(context)
      .setTitle("sample")
      .setMessage(message)
      .setPositiveButton(R.string.text_ok, onClickListener)
      .setOnDismissListener(onDismissListener)
      .create();
  alertDialog.show();
  return alertDialog;
}
 
Example 8
Source File: AptoideDialog.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
public static DialogFragment myAppInstall(String appName, DialogInterface.OnClickListener okListener, DialogInterface.OnDismissListener dismissListener) {

//        DialogFragment fragment = MyAppInstallDialog.newInstance(appName, okListener, dismissListener);
//
//        Bundle bundle = new Bundle();
//
//        bundle.putString("appName", appName);
//        fragment.setArguments(bundle);

        return MyAppInstallDialog.newInstance(appName, okListener, dismissListener);
    }
 
Example 9
Source File: DialogUtils.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
public static Dialog showTips(Context context, String title, String des, String btn, DialogInterface.OnDismissListener dismissListener) {
    AlertDialog.Builder builder = dialogBuilder(context, title, des);
    builder.setCancelable(true);
    builder.setPositiveButton(btn, null);
    Dialog dialog = builder.show();
    dialog.setCanceledOnTouchOutside(true);
    dialog.setOnDismissListener(dismissListener);
    return dialog;
}
 
Example 10
Source File: ProgressDialogUtil.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
public static Dialog createProgressDialog(Context context, String title, String des,  DialogInterface.OnDismissListener dismissListener,boolean cancelable) {
    ProgressDialog builder = dialogBuilder(context, title, des);
    builder.setCancelable(cancelable);
    builder.setCanceledOnTouchOutside(true);
    builder.setOnDismissListener(dismissListener);
    return builder;
}
 
Example 11
Source File: TimePickerDialog.java    From AlarmOn with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
public void setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
    mOnDismissListener = onDismissListener;
}
 
Example 12
Source File: DatePickerDialog.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
public void setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
    mOnDismissListener = onDismissListener;
}
 
Example 13
Source File: ProgressDialogUtil.java    From AndroidBase with Apache License 2.0 4 votes vote down vote up
public static Dialog createProgressDialog(Context context, int title, int des, int btn, DialogInterface.OnDismissListener dismissListener,boolean cancelable) {
    return createProgressDialog(context, context.getString(title), context.getString(des),  dismissListener,cancelable);
}
 
Example 14
Source File: TimePickerDialog.java    From date_picker_converter with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
public void setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
    mOnDismissListener = onDismissListener;
}
 
Example 15
Source File: AlertDialogFragment.java    From Android-Next with Apache License 2.0 4 votes vote down vote up
public Builder setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
    mParams.mOnDismissListener = onDismissListener;
    return this;
}
 
Example 16
Source File: DialogUtils.java    From SprintNBA with Apache License 2.0 4 votes vote down vote up
public static Dialog showTips(Context context, int title, int des, int btn, DialogInterface.OnDismissListener dismissListener) {
    return showTips(context, context.getString(title), context.getString(des), context.getString(btn), dismissListener);
}
 
Example 17
Source File: ChangeLogDialog.java    From KlyphMessenger with MIT License 4 votes vote down vote up
public ChangeLogDialog setOnDismissListener(final DialogInterface.OnDismissListener onDismissListener) {
    mOnDismissListener = onDismissListener;
    return this;
}
 
Example 18
Source File: BaseDialog.java    From talkback with Apache License 2.0 4 votes vote down vote up
/** Returns and shows the dialog with ok/cancel button. */
public AlertDialog showDialog() {
  // Only show one dialog at a time.
  if (dialog != null && dialog.isShowing()) {
    return dialog;
  }

  final DialogInterface.OnClickListener onClickListener =
      (dialog, buttonClicked) -> clickDialogInternal(buttonClicked);
  final DialogInterface.OnDismissListener onDismissListener = dialog -> dismissDialogInternal();

  AlertDialog.Builder dialogBuilder =
      new AlertDialog.Builder(context)
          .setTitle(dialogTitleResId)
          .setNegativeButton(android.R.string.cancel, onClickListener)
          .setPositiveButton(android.R.string.ok, onClickListener)
          .setOnDismissListener(onDismissListener)
          .setCancelable(true);

  String message = getMessageString();
  if (!TextUtils.isEmpty(message)) {
    dialogBuilder.setMessage(message);
  }
  View customizedView = getCustomizedView();
  if (customizedView != null) {
    dialogBuilder.setView(customizedView);
  }

  dialog = dialogBuilder.create();
  if (isSoftInputMode) {
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
  }
  if (context instanceof TalkBackService) {
    DialogUtils.setWindowTypeToDialog(dialog.getWindow());
  } else {
    LogUtils.v(
        TAG,
        "Create BaseDialog from context not instance of TalkBackService, class:"
            + context.getClass());
  }
  dialog.show();

  registerServiceDialog();
  return dialog;
}
 
Example 19
Source File: MeiCompatDialogDelegate.java    From MeiBaseModule with Apache License 2.0 4 votes vote down vote up
public void setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
    mOnDismissListener = onDismissListener;
}
 
Example 20
Source File: AbstractMaterialDialogBuilder.java    From AndroidMaterialDialog with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listener, which should be notified, when the dialog, which is created by the
 * builder, is dismissed for any reason.
 *
 * @param listener
 *         The listener, which should be set, as an instance of the type {@link
 *         DialogInterface.OnDismissListener}, or null, if no listener should be set
 * @return The builder, the method has been called upon, as an instance of the generic type
 * BuilderType
 */
public final BuilderType setOnDismissListener(
        @Nullable final DialogInterface.OnDismissListener listener) {
    getProduct().setOnDismissListener(listener);
    return self();
}