Java Code Examples for android.app.Dialog#setOnDismissListener()

The following examples show how to use android.app.Dialog#setOnDismissListener() . 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: BasePickerView.java    From Android-PickerView with Apache License 2.0 6 votes vote down vote up
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);
                }
            }
        });
    }
}
 
Example 2
Source File: BasePickerView.java    From AndroidFrame with Apache License 2.0 6 votes vote down vote up
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);
                }
            }
        });
    }

}
 
Example 3
Source File: DialogWithBlurredBackgroundLauncher.java    From fogger with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: PopupMenuDialog.java    From FileTransfer with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: BblDialogFragmentBase.java    From BubbleAlert with MIT License 6 votes vote down vote up
@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;
}
 
Example 6
Source File: BasePickerView.java    From Android-PickerView with Apache License 2.0 6 votes vote down vote up
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);
                }
            }
        });
    }
}
 
Example 7
Source File: SamlWebViewDialog.java    From Cirrus_depricated with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 8
Source File: BasicPopup.java    From a with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example 9
Source File: DialogSharePlatformSelector.java    From BiliShare with Apache License 2.0 5 votes vote down vote up
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setOnDismissListener(mDismiss);
    return dialog;
}
 
Example 10
Source File: DialogUtil.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 11
Source File: GoUtil.java    From android-lite-go 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 12
Source File: DialogPreference.java    From MaterialPreferenceLibrary with Apache License 2.0 5 votes vote down vote up
/**
     * 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();
    }
 
Example 13
Source File: DialogUtil.java    From android-common 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 14
Source File: DialogPreferenceV7.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 15
Source File: SignInActivity.java    From ribot-app-android with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 16
Source File: VKOpenAuthDialog.java    From cordova-social-vk with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 17
Source File: IReaderAdapter.java    From ClassifyView with Apache License 2.0 4 votes vote down vote up
@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;
            }
        });
    }*/

}
 
Example 18
Source File: MainActivity.java    From WhatsAppStatusSaver with Apache License 2.0 4 votes vote down vote up
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();
            }
        });
    }
 
Example 19
Source File: MainActivity.java    From android-ActionQueue with MIT License 4 votes vote down vote up
@Override
public void onAction() {
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    Dialog dialog = builder.setMessage(getBadge()).show();
    dialog.setOnDismissListener(mOnDismissListener);
}
 
Example 20
Source File: DynamicGridSizeFragment.java    From Trebuchet with GNU General Public License v3.0 4 votes vote down vote up
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();
}