Java Code Examples for android.content.DialogInterface.OnShowListener

The following are top voted examples for showing how to use android.content.DialogInterface.OnShowListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: PhoneChat   File: AsyncLicenseInfo.java   View source code 6 votes vote down vote up
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);
}
 
Example 2
Project: beautifullife   File: DialogUtils.java   View source code 6 votes vote down vote up
@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;
}
 
Example 3
Project: neo4art   File: AsyncLicenseInfo.java   View source code 6 votes vote down vote up
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);
}
 
Example 4
Project: neo4art   File: AsyncLicenseInfo.java   View source code 6 votes vote down vote up
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);
}
 
Example 5
Project: neo4art   File: AsyncLicenseInfo.java   View source code 6 votes vote down vote up
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);
}
 
Example 6
Project: itmarry   File: UserInfoActivity.java   View source code 6 votes vote down vote up
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();
	
}
 
Example 7
Project: RedditInPictures   File: SaveImageDialogFragment.java   View source code 6 votes vote down vote up
/**
 * 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();
                }
            });
        }
    };
}
 
Example 8
Project: RedditInPictures   File: LoginDialogFragment.java   View source code 6 votes vote down vote up
/**
 * 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();
                }
            });
        }
    };
}
 
Example 9
Project: tuxguitar   File: TGBrowserSettingsDialog.java   View source code 5 votes vote down vote up
@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;
}
 
Example 10
Project: TuxGuitar-1.3.1-fork   File: TGBrowserSettingsDialog.java   View source code 5 votes vote down vote up
@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;
}
 
Example 11
Project: cards-app   File: PrintPdfActivity.java   View source code 5 votes vote down vote up
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;
}
 
Example 12
Project: clip-blacklist   File: ItemEditDialog.java   View source code 5 votes vote down vote up
@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;
}
 
Example 13
Project: okwallet   File: BackupWalletDialogFragment.java   View source code 4 votes vote down vote up
@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;
}
 
Example 14
Project: ticdesign   File: ContextMenuBuilder.java   View source code 4 votes vote down vote up
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());
    }
 
Example 15
Project: ombuds-android   File: BackupWalletDialogFragment.java   View source code 4 votes vote down vote up
@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;
}
 
Example 16
Project: ombuds-android   File: EncryptKeysDialogFragment.java   View source code 4 votes vote down vote up
@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;
}
 
Example 17
Project: ics-openconnect   File: ConfirmDialog.java   View source code 4 votes vote down vote up
@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();
	}
}
 
Example 18
Project: AndroidMaterialPreferences   File: DialogPreference.java   View source code 2 votes vote down vote up
/**
 * 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;
}