android.app.Dialog#setOnDismissListener ( )源码实例Demo

下面列出了android.app.Dialog#setOnDismissListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: a   文件: BasicPopup.java
private void initDialog() {
    contentLayout = new FrameLayout(activity);
    contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
    contentLayout.setFocusable(true);
    contentLayout.setFocusableInTouchMode(true);
    dialog = new Dialog(activity);
    dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
    dialog.setCancelable(true);//按返回键取消窗体
    dialog.setOnKeyListener(this);
    dialog.setOnDismissListener(this);
    Window window = dialog.getWindow();
    if (window != null) {
        window.setGravity(Gravity.BOTTOM);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        //AndroidRuntimeException: requestFeature() must be called before adding content
        window.requestFeature(Window.FEATURE_NO_TITLE);
        window.setContentView(contentLayout);
    }
    setSize(screenWidthPixels, WRAP_CONTENT);
}
 
源代码2 项目: AndroidFrame   文件: BasePickerView.java
public void createDialog() {
    if (dialogView != null) {
        mDialog = new Dialog(context, R.style.custom_dialog2);
        mDialog.setCancelable(cancelable);//不能点外面取消,也不 能点back取消
        mDialog.setContentView(dialogView);

        mDialog.getWindow().setWindowAnimations(R.style.pickerview_dialogAnim);
        mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (onDismissListener != null) {
                    onDismissListener.onDismiss(BasePickerView.this);
                }
            }
        });
    }

}
 
public Dialog showDialog(Dialog dialog) {
    this.dialog = dialog;
    try {
        blurredBackgroundAdapter.prepareBlurredBackgroundForActivity(activity);
        setBlurBackground();
        addBlurredLayer();
        turnOffNativeBackgroundBehaviour(dialog);
    } catch(RuntimeException e) {
        Log.e(TAG, "Error during preparing blurred background", e);
        blurredBackgroundAdapter.reset();
    }

    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
            decorView.removeView(blurImageView);
        }
    });
    dialog.show();
    return dialog;
}
 
源代码4 项目: FileTransfer   文件: PopupMenuDialog.java
public PopupMenuDialog builder() {
    View view = LayoutInflater.from(context).inflate(
            R.layout.layout_popup_menu_dialog, null);

    view.setMinimumWidth(display.getWidth());

    dialog = new Dialog(context, R.style.PopupMenuDialogStyle);
    dialog.setContentView(view);
    mUnbinder = ButterKnife.bind(this, dialog);
    dialog.setOnDismissListener(this::onDialogDismiss);

    Window dialogWindow = dialog.getWindow();
    dialogWindow.setGravity(Gravity.LEFT | Gravity.BOTTOM);
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    lp.x = 0;
    lp.y = 0;
    dialogWindow.setAttributes(lp);

    return this;
}
 
源代码5 项目: BubbleAlert   文件: BblDialogFragmentBase.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    Dialog dialog = new Dialog(getActivity());
    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnDismissListener(this);


    dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    return dialog;
}
 
源代码6 项目: Cirrus_depricated   文件: SamlWebViewDialog.java
@Override
public void onDestroyView() {
    Log_OC.v(TAG, "onDestroyView");
    
    if (mSsoWebView.getParent() != null) {
        ((ViewGroup)mSsoWebView.getParent()).removeView(mSsoWebView);
    }
    
    mSsoWebView.setWebViewClient(null);
    
    // Work around bug: http://code.google.com/p/android/issues/detail?id=17423
    Dialog dialog = getDialog();
    if ((dialog != null)) {
        dialog.setOnDismissListener(null);
    }
    
    super.onDestroyView();
}
 
源代码7 项目: Android-PickerView   文件: BasePickerView.java
public void createDialog() {
    if (dialogView != null) {
        mDialog = new Dialog(context, R.style.custom_dialog2);
        mDialog.setCancelable(mPickerOptions.cancelable);//不能点外面取消,也不能点back取消
        mDialog.setContentView(dialogView);

        Window dialogWindow = mDialog.getWindow();
        if (dialogWindow != null) {
            dialogWindow.setWindowAnimations(R.style.picker_view_scale_anim);
            dialogWindow.setGravity(Gravity.CENTER);//可以改成Bottom
        }

        mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (onDismissListener != null) {
                    onDismissListener.onDismiss(BasePickerView.this);
                }
            }
        });
    }
}
 
源代码8 项目: Android-PickerView   文件: BasePickerView.java
public void createDialog() {
    if (dialogView != null) {
        mDialog = new Dialog(context, R.style.custom_dialog2);
        mDialog.setCancelable(mPickerOptions.cancelable);//不能点外面取消,也不能点back取消
        mDialog.setContentView(dialogView);

        Window dialogWindow = mDialog.getWindow();
        if (dialogWindow != null) {
            dialogWindow.setWindowAnimations(R.style.picker_view_scale_anim);
            dialogWindow.setGravity(Gravity.CENTER);//可以改成Bottom
        }

        mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (onDismissListener != null) {
                    onDismissListener.onDismiss(BasePickerView.this);
                }
            }
        });
    }
}
 
源代码9 项目: cordova-social-vk   文件: VKOpenAuthDialog.java
public void show(@NonNull Activity activity, Bundle bundle, int reqCode, @Nullable VKError vkError) {
	mVkError = vkError;
	mBundle = bundle;
	mReqCode = reqCode;
	mView = View.inflate(activity, R.layout.vk_open_auth_dialog, null);

	mProgress = mView.findViewById(R.id.progress);
	mWebView = (WebView) mView.findViewById(R.id.copyUrl);

	final Dialog dialog = new Dialog(activity, R.style.VKAlertDialog);
	dialog.setContentView(mView);
	dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
		@Override
		public void onCancel(DialogInterface dialogInterface) {
			dialog.dismiss();
		}
	});
	dialog.setOnDismissListener(this);
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		dialog.getWindow().setStatusBarColor(Color.TRANSPARENT);
	}

	mDialog = dialog;
	mDialog.show();

	loadPage();
}
 
源代码10 项目: ribot-app-android   文件: SignInActivity.java
private void showNoPlayServicesError() {
    Dialog playServicesDialog = DialogFactory.createSimpleOkErrorDialog(
            SignInActivity.this,
            R.string.dialog_error_title,
            R.string.error_message_play_services);

    playServicesDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            finish();
        }
    });
    playServicesDialog.show();
}
 
源代码11 项目: BiliShare   文件: DialogSharePlatformSelector.java
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setOnDismissListener(mDismiss);
    return dialog;
}
 
源代码12 项目: libcommon   文件: DialogPreferenceV7.java
/**
 * Shows the dialog associated with this Preference. This is normally initiated
 * automatically on clicking on the preference. Call this method if you need to
 * show the dialog on some other event.
 *
 * @param state Optional instance state to restore on the dialog
 */
protected void showDialog(final Bundle state) {
	Context context = getContext();
	
	mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE;
	// XXX 本当はDialogFragmentにしたいけど親ActivityのFragmentManagerを取得する方法がないのでとりあえずAlertDialogのままにする
	mBuilder = new AlertDialog.Builder(context)
		.setTitle(mDialogTitle)
		.setIcon(mDialogIcon)
		.setPositiveButton(mPositiveButtonText, this)
		.setNegativeButton(mNegativeButtonText, this);
	
	View contentView = onCreateDialogView();
	if (contentView != null) {
		onBindDialogView(contentView);
		mBuilder.setView(contentView);
	} else {
		mBuilder.setMessage(mDialogMessage);
	}
	
	onPrepareDialogBuilder(mBuilder);

	// Create the dialog
	final Dialog dialog = mDialog = mBuilder.create();
	if (state != null) {
		dialog.onRestoreInstanceState(state);
	}
	if (needInputMethod()) {
		requestInputMethod(dialog);
	}
	dialog.setOnDismissListener(this);
	dialog.show();
}
 
源代码13 项目: android-common   文件: DialogUtil.java
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;
}
 
/**
     * Shows the dialog associated with this Preference. This is normally initiated
     * automatically on clicking on the preference. Call this method if you need to
     * show the dialog on some other event.
     *
     * @param state Optional instance state to restore on the dialog
     */
    protected void showDialog(Bundle state) {
        Context context = getContext();

        mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE;
        mBuilder = new AlertDialog.Builder(context)
                .setTitle(mDialogTitle)
                .setIcon(mDialogIcon)
                .setPositiveButton(mPositiveButtonText, this)
                .setNegativeButton(mNegativeButtonText, this);
        View contentView = onCreateDialogView();
        if (contentView != null) {
            onBindDialogView(contentView);
            mBuilder.setView(contentView);
        } else {
            mBuilder.setMessage(mDialogMessage);
        }

        onPrepareDialogBuilder(mBuilder);
        PreferenceManagerEx.getInstance().registerOnActivityDestroyListener(getPreferenceManager(), this);

// Create the dialog
        final Dialog dialog = mDialog = mBuilder.create();
        if (state != null) {
            dialog.onRestoreInstanceState(state);
        }
        if (needInputMethod()) {
            requestInputMethod(dialog);
        }
        dialog.setOnDismissListener(this);
        dialog.show();
    }
 
源代码15 项目: android-lite-go   文件: GoUtil.java
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;
}
 
源代码16 项目: AndroidBase   文件: DialogUtil.java
public static Dialog createDialog(Context context, String title, String des, String btn, DialogInterface.OnDismissListener dismissListener,boolean cancelable) {
    AlertDialog.Builder builder = dialogBuilder(context, title, des);
    builder.setCancelable(cancelable);
    builder.setPositiveButton(btn, null);
    Dialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(true);
    dialog.setOnDismissListener(dismissListener);
    return dialog;
}
 
源代码17 项目: android-ActionQueue   文件: MainActivity.java
@Override
public void onAction() {
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    Dialog dialog = builder.setMessage(getBadge()).show();
    dialog.setOnDismissListener(mOnDismissListener);
}
 
源代码18 项目: WhatsAppStatusSaver   文件: MainActivity.java
public void showImagePopup(Point p, final String uri) {
        Activity context = MainActivity.this;
        //COMPLETED solving video problem

        final Dialog dialog = new Dialog(context);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.image_popup_layout);
        dialog.show();
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.copyFrom(dialog.getWindow().getAttributes());
        dialog.getWindow().setAttributes(lp);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
        dialog.getWindow().setDimAmount(0);


        // Getting a reference to Close button, and close the popup when clicked.
        FloatingActionButton close = (FloatingActionButton) dialog.findViewById(R.id.close_image_popup_button);
        ImageView statusImage = (ImageView) dialog.findViewById(R.id.full_status_image_view);
        final SimpleExoPlayerView simpleExoPlayerView = dialog.findViewById(R.id.full_status_video_view);
        final SimpleExoPlayer player;
        if (uri.endsWith(".jpg")) {
            GlideApp.with(context).load(uri).into(statusImage);
        } else if (uri.endsWith(".mp4")) {
            statusImage.setVisibility(View.GONE);
            simpleExoPlayerView.setVisibility(View.VISIBLE);
            Uri myUri = Uri.parse(uri); // initialize Uri here

            // 1. Create a default TrackSelector
            BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
            TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
            TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

// 2. Create a default LoadControl
            LoadControl loadControl = new DefaultLoadControl();

// 3. Create the player
            player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);

//Set media controller
            simpleExoPlayerView.setUseController(true);
            simpleExoPlayerView.requestFocus();

// Bind the player to the view.
            simpleExoPlayerView.setPlayer(player);

            //Measures bandwidth during playback. Can be null if not required.
            DefaultBandwidthMeter bandwidthMeterA = new DefaultBandwidthMeter();
//Produces DataSource instances through which media data is loaded.
            DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this, Util.
                    getUserAgent(this, "exoplayer2example"), bandwidthMeterA);
//Produces Extractor instances for parsing the media data.
            ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();

            MediaSource videoSource = new ExtractorMediaSource(myUri, dataSourceFactory, extractorsFactory, null, null);
            player.prepare(videoSource);
            player.setPlayWhenReady(true); //run file/link when ready to play.
            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    player.release();
                }
            });

        }
        close.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
//                popup.dismiss();
                dialog.cancel();
            }
        });
    }
 
源代码19 项目: ClassifyView   文件: IReaderAdapter.java
@Override
protected void onSubDialogShow(Dialog dialog, int parentPosition) {
    dialog.setOnDismissListener(mDismissListener);
    //当次级窗口显示时需要修改标题
    final ViewGroup contentView = (ViewGroup) dialog.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
    final TextView selectAll = (TextView) contentView.findViewById(R.id.text_select_all);
    TextView title = (TextView) contentView.findViewById(R.id.text_title);
    final EditText editText = (EditText) contentView.findViewById(R.id.edit_title);
    FrameLayout subContainer = (FrameLayout) contentView.findViewById(R.id.sub_container);
    final IReaderMockDataGroup mockDataGroup = (IReaderMockDataGroup) mMockSource.get(parentPosition);
    mSubObserver.setBindResource(mockDataGroup, selectAll, getMainAdapter(),getSubAdapter(),parentPosition);
    if(!mObservable.isRegister(mSubObserver)) mObservable.registerObserver(mSubObserver);
    selectAll.setVisibility(mEditMode ? mSubEditMode ? View.GONE : View.VISIBLE : View.GONE);
    title.setText(String.valueOf(mockDataGroup.getCategory()));
    /*if(Build.VERSION.SDK_INT >= 19) {
        title.setOnClickListener(new View.OnClickListener() {
            @TargetApi(Build.VERSION_CODES.KITKAT)
            @Override
            public void onClick(View v) {
                mSubEditMode = true;
                selectAll.setVisibility(View.GONE);
                editText.setText(String.valueOf(mockDataGroup.getCategory()));
                editText.setSelection(0,editText.getText().toString().length());
                int originWidth = editText.getWidth();
                editText.setWidth(0);
                TransitionManager.beginDelayedTransition(contentView);
                editText.setWidth(originWidth);
            }
        });
        editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                switch (actionId){
                    case KeyEvent.KEYCODE_ENTER:
                        break;
                }
                return false;
            }
        });
    }*/

}
 
源代码20 项目: Trebuchet   文件: DynamicGridSizeFragment.java
private void showNumberPicker() {
    mDialog = new Dialog(getActivity());
    mDialog.setTitle(getResources().getString(
            R.string.preferences_interface_homescreen_custom));
    mDialog.setContentView(R.layout.custom_grid_size_dialog);

    NumberPicker nPRows = (NumberPicker) mDialog.findViewById(R.id.custom_rows);
    NumberPicker nPColumns = (NumberPicker) mDialog.findViewById(R.id.custom_columns);

    InvariantDeviceProfile grid = getInvariantDeviceProfile();
    int rows = grid.numRowsBase;
    int columns = grid.numColumnsBase;

    nPRows.setMinValue(Math.max(MIN_DYNAMIC_GRID_ROWS, rows - InvariantDeviceProfile.GRID_SIZE_MIN));
    nPRows.setMaxValue(rows + InvariantDeviceProfile.GRID_SIZE_MAX);
    nPRows.setValue(mCustomGridRows);
    nPRows.setWrapSelectorWheel(false);
    nPRows.setOnValueChangedListener(this);
    nPRows.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    nPColumns.setMinValue(Math.max(MIN_DYNAMIC_GRID_COLUMNS,
            columns - InvariantDeviceProfile.GRID_SIZE_MIN));
    nPColumns.setMaxValue(columns + InvariantDeviceProfile.GRID_SIZE_MAX);
    nPColumns.setValue(mCustomGridColumns);
    nPColumns.setWrapSelectorWheel(false);
    nPColumns.setOnValueChangedListener(this);
    nPColumns.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

    Button button = (Button) mDialog.findViewById(R.id.dialog_confirm_button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mDialog != null) {
                mDialog.dismiss();
            }
        }
    });

    mDialog.setOnDismissListener(this);
    mDialog.show();
}