Java 类android.content.DialogInterface.OnShowListener 实例源码

项目:PhoneChat    文件:AsyncLicenseInfo.java   
protected void onPostExecute(final AlertDialog.Builder alertDialogBuilder) {
  Runnable runnable = new Runnable() {

    @Override
    public void run() {
   // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      alertDialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(DialogInterface arg0) {
          mProgress.dismiss();
        }

      });

      // show it
      alertDialog.show();
    }

  };
  mActivity.runOnUiThread(runnable);
}
项目:beautifullife    文件:DialogUtils.java   
@NonNull
public static Dialog createLoadingDialog(@NonNull Context context) {

    Dialog loadingDialog = new Dialog(context, R.style.DDULoadingDialog);

    loadingDialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            // 提示加载时,关闭Toast提示
            ToastUtils.cancel();
        }
    });

    loadingDialog.setCancelable(true);
    loadingDialog.setContentView(R.layout.dialog_loading);
    return loadingDialog;
}
项目:neo4art    文件:AsyncLicenseInfo.java   
protected void onPostExecute(final AlertDialog.Builder alertDialogBuilder) {
  Runnable runnable = new Runnable() {

    @Override
    public void run() {
   // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      alertDialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(DialogInterface arg0) {
          mProgress.dismiss();
        }

      });

      // show it
      alertDialog.show();
    }

  };
  mActivity.runOnUiThread(runnable);
}
项目:neo4art    文件:AsyncLicenseInfo.java   
protected void onPostExecute(final AlertDialog.Builder alertDialogBuilder) {
  Runnable runnable = new Runnable() {

    @Override
    public void run() {
   // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      alertDialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(DialogInterface arg0) {
          mProgress.dismiss();
        }

      });

      // show it
      alertDialog.show();
    }

  };
  mActivity.runOnUiThread(runnable);
}
项目:neo4art    文件:AsyncLicenseInfo.java   
protected void onPostExecute(final AlertDialog.Builder alertDialogBuilder) {
  Runnable runnable = new Runnable() {

    @Override
    public void run() {
   // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      alertDialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(DialogInterface arg0) {
          mProgress.dismiss();
        }

      });

      // show it
      alertDialog.show();
    }

  };
  mActivity.runOnUiThread(runnable);
}
项目:itmarry    文件:UserInfoActivity.java   
public void showSendMsgDialog()
{
    if ( editMsgDialog == null ) {
        editMsgText = new EditText(this);
        editMsgText.setHint(String.format( getResources().getString(R.string.dialog_hint_sendmsg), nameString) );
        editMsgText.setHeight(300);
        editMsgText.setGravity(Gravity.TOP);
        editMsgText.setTextSize(24);
        editMsgDialog = new Builder(this).setTitle(getResources().getString(R.string.dialog_title_sendmsg)).
                setView(editMsgText).setNegativeButton(getString(R.string.dialog_button_cancel), null).
                setPositiveButton(getResources().getString(R.string.dialog_button_send), dialogClickListener).create();
        editMsgDialog.setOnShowListener(new OnShowListener() {

            @Override
            public void onShow(DialogInterface dialog) {
                // TODO Auto-generated method stub
                InputMethodManager imm=(InputMethodManager)UserInfoActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE); 
                imm.showSoftInput(editMsgText, 0);
                editMsgText.requestFocus();
            }
        });
    }

    editMsgDialog.show();

}
项目:RedditInPictures    文件:SaveImageDialogFragment.java   
/**
 * We have to override setOnShowListener here (min API level 8) in order to validate
 * the inputs before closing the dialog. Just overriding setPositiveButton closes the
 * automatically when the button is pressed
 *
 * @return The onShowListener for the AlertDialog
 */
private OnShowListener getDialogOnShowListener() {
    return new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            Button save = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            save.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    saveImage();
                }
            });
        }
    };
}
项目:RedditInPictures    文件:LoginDialogFragment.java   
/**
 * We have to override setOnShowListener here (min API level 8) in order to validate
 * the inputs before closing the dialog. Just overriding setPositiveButton closes the
 * automatically when the button is pressed
 *
 * @return The onShowListener for the AlertDialog
 */
private OnShowListener getDialogOnShowListener() {
    return new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            Button login = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            login.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    doLogin();
                }
            });
        }
    };
}
项目:tuxguitar    文件:TGBrowserSettingsDialog.java   
@SuppressLint("InflateParams")
public Dialog onCreateDialog() {
    final View view = getActivity().getLayoutInflater().inflate(R.layout.view_browser_settings_fs_dialog, null);

    this.fillListView(view);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.browser_settings_fs_dlg_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.global_button_ok, null);
    builder.setNegativeButton(R.string.global_button_cancel, null);

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new OnShowListener() {
        public void onShow(DialogInterface dlg) {
            dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if( createSettings(view) ) {
                        dialog.dismiss();
                    }
                }
            });
        }
    });

    return dialog;
}
项目:TuxGuitar-1.3.1-fork    文件:TGBrowserSettingsDialog.java   
@SuppressLint("InflateParams")
public Dialog onCreateDialog() {
    final View view = getActivity().getLayoutInflater().inflate(R.layout.view_browser_settings_fs_dialog, null);

    this.fillListView(view);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.browser_settings_fs_dlg_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.global_button_ok, null);
    builder.setNegativeButton(R.string.global_button_cancel, null);

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new OnShowListener() {
        public void onShow(DialogInterface dlg) {
            dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if( createSettings(view) ) {
                        dialog.dismiss();
                    }
                }
            });
        }
    });

    return dialog;
}
项目:cards-app    文件:PrintPdfActivity.java   
private AlertDialog createDialog(){
    LayoutInflater inflater=getLayoutInflater();
    final View v=inflater.inflate(R.layout.dialog_filename_view, null);
    final EditText input=(EditText) v.findViewById(R.id.filename_input);

    AlertDialog.Builder builder=new Builder(context)
    .setView(v)
    .setPositiveButton(getResources().getString(R.string.str_ok), null)
    .setNegativeButton(getResources().getString(R.string.str_cancel), null);

    final AlertDialog dialog=builder.create();
    dialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(DialogInterface d) {
            // TODO Auto-generated method stub
            Button b = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
               b.setOnClickListener(new View.OnClickListener() {

                   @Override
                   public void onClick(View view) {
                       // TODO Do something
                    String name=input.getText().toString();
                    if (name==null||name.equals("")) Toast.makeText(context, getString(R.string.str_input_name), Toast.LENGTH_SHORT).show();
                    else if (name.trim().equals(""))Toast.makeText(context,getString(R.string.str_not_correct_name), Toast.LENGTH_SHORT).show();
                    else {
                        sendPdf(name);
                        dialog.dismiss();
                        sended=true;
                    }
                   }
               });
           }
    });
    return dialog;
}
项目:clip-blacklist    文件:ItemEditDialog.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = this.getArguments();
    final boolean appendNew = args == null || !args.containsKey(KEY_ITEM);
    this.mItem = new BlacklistItem(true);
    if (!appendNew) {
        this.mItem.load(args, KEY_ITEM);
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
    LayoutInflater inflater = this.getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.dialog_edit, null);
    this.initFromView(view);
    this.setupListeners();
    this.setViewFromItem();
    builder
        .setView(view)
        .setTitle(R.string.dialog_prompt)
        .setPositiveButton(android.R.string.ok, null)
        .setNegativeButton(android.R.string.cancel, null);
    final AlertDialog d = builder.create();
    d.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            Button okButton = d.getButton(Dialog.BUTTON_POSITIVE);
            okButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (setItemFromView()) {
                        if (mCallback != null) {
                            mCallback.onFinishedEdit(ItemEditDialog.this, mItem, appendNew);
                        }
                        d.dismiss();
                    }
                }
            });
        }
    });
    return d;
}
项目:okwallet    文件:BackupWalletDialogFragment.java   
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final View view = LayoutInflater.from(activity).inflate(R.layout.backup_wallet_dialog, null);

    passwordView = (EditText) view.findViewById(R.id.backup_wallet_dialog_password);
    passwordView.setText(null);

    passwordAgainView = (EditText) view.findViewById(R.id.backup_wallet_dialog_password_again);
    passwordAgainView.setText(null);

    passwordStrengthView = (TextView) view.findViewById(R.id.backup_wallet_dialog_password_strength);

    passwordMismatchView = view.findViewById(R.id.backup_wallet_dialog_password_mismatch);

    showView = (CheckBox) view.findViewById(R.id.backup_wallet_dialog_show);

    final TextView warningView = (TextView) view.findViewById(R.id.backup_wallet_dialog_warning_encrypted);
    warningView.setVisibility(wallet.isEncrypted() ? View.VISIBLE : View.GONE);

    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.export_keys_dialog_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.button_ok, null); // dummy, just to make it show
    builder.setNegativeButton(R.string.button_cancel, null);
    builder.setCancelable(false);

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(final DialogInterface d) {
            positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
            positiveButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(final View v) {
                    handleGo();
                }
            });

            passwordView.addTextChangedListener(textWatcher);
            passwordAgainView.addTextChangedListener(textWatcher);

            showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView, passwordAgainView));

            BackupWalletDialogFragment.this.dialog = dialog;
            updateView();
        }
    });

    return dialog;
}
项目:ticdesign    文件:ContextMenuBuilder.java   
public void open() {

        mMenuDialog = new Builder(getContext(), R.style.Theme_Ticwear_Dialog_Alert_ContextMenu)
                .setCustomTitle(mHeaderView)
                .setTitle(mTitle)
                .setIcon(mIcon)
                .setOnDismissListener(new OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        close();
                    }
                })
                .create();

        // Use dialog context to match Ticwear theme.
        ViewGroup layout = createDialogContent(mMenuDialog.getContext());
        mMenuDialog.setView(layout);

        mMenuLayout.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(MenuItem item) {
                if (item != null) {
                    performItemAction(item);
                }
                close();
            }
        });

        onItemsChanged(true);

        final int maskColor = getResources().getColor(R.color.tic_background_mask_dark);
        final int animDurationLong = getResources().getInteger(android.R.integer.config_longAnimTime);

        mMenuDialog.setOnShowListener(new OnShowListener() {
            @Override
            public void onShow(DialogInterface di) {
                mMenuLayout.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (mMenuDialog == null) {
                            return;
                        }
                        BlurBehind.from(getContext())
                                .animate(animDurationLong)
                                .color(maskColor)
                                .sampling(2)
                                .capture(getBackgroundWindow())
                                .into(mMenuDialog.getWindow());
                    }
                }, 500);
            }
        });

        // Show dialog then blur.
        mMenuDialog.show();
        BlurBehind.from(getContext())
                .color(maskColor)
                .sampling(2)
                .capture(getBackgroundWindow())
                .into(mMenuDialog.getWindow());
    }
项目:ombuds-android    文件:BackupWalletDialogFragment.java   
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState)
{
    final View view = LayoutInflater.from(activity).inflate(R.layout.backup_wallet_dialog, null);

    passwordView = (EditText) view.findViewById(R.id.backup_wallet_dialog_password);
    passwordView.setText(null);

    passwordAgainView = (EditText) view.findViewById(R.id.backup_wallet_dialog_password_again);
    passwordAgainView.setText(null);

    passwordStrengthView = (TextView) view.findViewById(R.id.backup_wallet_dialog_password_strength);

    passwordMismatchView = view.findViewById(R.id.backup_wallet_dialog_password_mismatch);

    showView = (CheckBox) view.findViewById(R.id.backup_wallet_dialog_show);

    final TextView warningView = (TextView) view.findViewById(R.id.backup_wallet_dialog_warning_encrypted);
    warningView.setVisibility(wallet.isEncrypted() ? View.VISIBLE : View.GONE);

    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.export_keys_dialog_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.button_ok, null); // dummy, just to make it show
    builder.setNegativeButton(R.string.button_cancel, null);
    builder.setCancelable(false);

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new OnShowListener()
    {
        @Override
        public void onShow(final DialogInterface d)
        {
            positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
            positiveButton.setOnClickListener(new OnClickListener()
            {
                @Override
                public void onClick(final View v)
                {
                    handleGo();
                }
            });

            passwordView.addTextChangedListener(textWatcher);
            passwordAgainView.addTextChangedListener(textWatcher);

            showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView, passwordAgainView));

            BackupWalletDialogFragment.this.dialog = dialog;
            updateView();
        }
    });

    return dialog;
}
项目:ombuds-android    文件:EncryptKeysDialogFragment.java   
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState)
{
    final View view = LayoutInflater.from(activity).inflate(R.layout.encrypt_keys_dialog, null);

    oldPasswordGroup = view.findViewById(R.id.encrypt_keys_dialog_password_old_group);

    oldPasswordView = (EditText) view.findViewById(R.id.encrypt_keys_dialog_password_old);
    oldPasswordView.setText(null);

    newPasswordView = (EditText) view.findViewById(R.id.encrypt_keys_dialog_password_new);
    newPasswordView.setText(null);

    badPasswordView = view.findViewById(R.id.encrypt_keys_dialog_bad_password);

    passwordStrengthView = (TextView) view.findViewById(R.id.encrypt_keys_dialog_password_strength);

    showView = (CheckBox) view.findViewById(R.id.encrypt_keys_dialog_show);

    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.encrypt_keys_dialog_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.button_ok, null); // dummy, just to make it show
    builder.setNegativeButton(R.string.button_cancel, null);
    builder.setCancelable(false);

    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);

    dialog.setOnShowListener(new OnShowListener()
    {
        @Override
        public void onShow(final DialogInterface d)
        {
            positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);

            positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
            positiveButton.setOnClickListener(new OnClickListener()
            {
                @Override
                public void onClick(final View v)
                {
                    handleGo();
                }
            });

            oldPasswordView.addTextChangedListener(textWatcher);
            newPasswordView.addTextChangedListener(textWatcher);

            showView = (CheckBox) dialog.findViewById(R.id.encrypt_keys_dialog_show);
            showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(newPasswordView, oldPasswordView));
            showView.setChecked(true);

            EncryptKeysDialogFragment.this.dialog = dialog;
            updateView();
        }
    });

    return dialog;
}
项目:ics-openconnect    文件:ConfirmDialog.java   
@Override
protected void onResume() {
    super.onResume();
    try {
        mPackage = getCallingPackage();
        if (mPackage==null) {
            finish();
            return;
        }


        PackageManager pm = getPackageManager();
        ApplicationInfo app = pm.getApplicationInfo(mPackage, 0);

        View view = View.inflate(this, R.layout.api_confirm, null);
        ((ImageView) view.findViewById(R.id.icon)).setImageDrawable(app.loadIcon(pm));
        ((TextView) view.findViewById(R.id.prompt)).setText(
                getString(R.string.prompt, app.loadLabel(pm), getString(R.string.app)));
        ((CompoundButton) view.findViewById(R.id.check)).setOnCheckedChangeListener(this);


        Builder builder = new AlertDialog.Builder(this);

        builder.setView(view);

        builder.setIconAttribute(android.R.attr.alertDialogIcon);
        builder.setTitle(android.R.string.dialog_alert_title);
        builder.setPositiveButton(android.R.string.ok,this);
        builder.setNegativeButton(android.R.string.cancel,this);

        mAlert = builder.create();
        mAlert.setCanceledOnTouchOutside(false);

        mAlert.setOnShowListener (new OnShowListener() {

            @Override
            public void onShow(DialogInterface dialog) {
                mButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
                mButton.setEnabled(false);

            }
        });

        //setCloseOnTouchOutside(false);

        mAlert.show();

    } catch (Exception e) {
        Log.e(TAG, "onResume", e);
        finish();
    }
}
项目:AndroidMaterialPreferences    文件:DialogPreference.java   
/**
 * Sets the listener, which should be notified, when the preference's dialog has been shown.
 *
 * @param listener
 *         The listener, which should be set, as an instance of the type {@link OnShowListener}
 *         or null, if no listener should be notified
 */
public final void setOnShowListener(@Nullable final OnShowListener listener) {
    onShowListener = listener;
}