Java Code Examples for android.content.DialogInterface.OnShowListener

The following examples show how to use android.content.DialogInterface.OnShowListener. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: ticdesign   Source File: ContextMenuBuilder.java    License: Apache License 2.0 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) {
                if (!isOpen() || mMenuDialog == null) {
                    return;
                }
                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 2
Source Project: android   Source File: ConfirmAPIActivity.java    License: GNU General Public License v3.0 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 3
/**
 * 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;
}