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

The following examples show how to use android.app.Dialog#setOnShowListener() . 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: BaseBottomSheetDialog.java    From mvvm-template with GNU General Public License v3.0 6 votes vote down vote up
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(dialogInterface -> {
        if (ViewHelper.isTablet(getActivity())) {
            if (dialog.getWindow() != null) {
                dialog.getWindow().setLayout(
                        ViewGroup.LayoutParams.WRAP_CONTENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
            }
        }
        onDialogIsShowing();
    });
    dialog.setOnKeyListener((dialog1, keyCode, event) -> {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            isAlreadyHidden = true;
            onDismissedByScrolling();
        }
        return false;
    });
    return dialog;
}
 
Example 2
Source File: BaseDialogFragment.java    From AndroidTabbedDialog with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getActivity());

    Bundle args = getArguments();
    if (args != null) {
        dialog.setCanceledOnTouchOutside(
                args.getBoolean(BaseDialogBuilder.ARG_CANCELABLE_ON_TOUCH_OUTSIDE));
    }
    /*
    * disable the actual title of a dialog cause custom dialog title is rendering through custom layout
     */
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    dialog.setOnShowListener(this);
    return dialog;
}
 
Example 3
Source File: BottomSheetDialogFragmentExample.java    From MaterialTapTargetPrompt with Apache License 2.0 6 votes vote down vote up
@NotNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    View contentView = View.inflate(getContext(), R.layout.fragment_bottom_sheet, null);
    dialog.setContentView(contentView);

    dialog.setOnShowListener(dialog1 -> new MaterialTapTargetPrompt.Builder(new DialogResourceFinder(getDialog()), 0)
            .setPrimaryText(R.string.search_prompt_title)
            .setSecondaryText(R.string.search_prompt_description)
            .setAnimationInterpolator(new FastOutSlowInInterpolator())
            .setMaxTextWidth(R.dimen.tap_target_menu_max_width)
            .setIcon(R.drawable.ic_search)
            .setTarget(R.id.bs_search)
            .show());
    return dialog;
}
 
Example 4
Source File: TravelTimePicker.java    From msdkui-android with Apache License 2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity())
            .setNegativeButton(R.string.msdkui_cancel, null)
            .setPositiveButton(R.string.msdkui_ok, null);

    final View view = View.inflate(getActivity(), R.layout.travel_time_picker, null);
    dialogBuilder.setView(view);

    mTabLayout = (TabLayout) view.findViewById(R.id.picker_tab);
    mDatePicker = (DatePicker) view.findViewById(R.id.travel_date);
    mTimePicker = (TimePicker) view.findViewById(R.id.travel_time);
    mTimePicker.setIs24HourView(DateFormat.is24HourFormat(getActivity()));

    updateDefaultValues();
    updateTab(savedInstanceState);
    updateDatePicker(savedInstanceState);
    updateTimePicker(savedInstanceState);
    updateVisibility(savedInstanceState);

    final Dialog dialog = dialogBuilder.create();
    dialog.setOnShowListener(mOnShowListener);
    return dialog;
}
 
Example 5
Source File: ExpandableMenuOverlay.java    From ExpandableButtonMenu with Apache License 2.0 5 votes vote down vote up
public void init(AttributeSet attrs) {
    // We create a fake dialog which dims the screen and we display the expandable menu as content
    mDialog = new Dialog(getContext(), android.R.style.Theme_Translucent_NoTitleBar);
    mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    WindowManager.LayoutParams lp = mDialog.getWindow().getAttributes();
    lp.dimAmount = dimAmount;
    mDialog.getWindow().setAttributes(lp);

    mButtonMenu = new ExpandableButtonMenu(getContext(), attrs);
    mButtonMenu.setButtonMenuParentOverlay(this);

    mDialog.setContentView(mButtonMenu);
    mDialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            setVisibility(View.INVISIBLE);
            mButtonMenu.toggle();
        }
    });

    // Catch events when keyboard button are clicked. Used to dismiss the menu
    // on 'back' button
    mDialog.setOnKeyListener(this);

    // Clicking this view will expand the button menu
    setOnClickListener(this);

}
 
Example 6
Source File: ShareChooserDialog.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.getWindow().setLayout(
                    parentWidth - Utils.dpToPx(0, getContext()), // Set margins here!
                    ViewGroup.LayoutParams.MATCH_PARENT);
        }
    });
    return dialog;
}
 
Example 7
Source File: SearchView.java    From Material-SearchView with Apache License 2.0 5 votes vote down vote up
private void initWindowParams() {
    Dialog dialog = getDialog();
    Window window = null;
    if (dialog != null) {
        window = dialog.getWindow();
    }

    if (dialog == null || window == null) {
        return;
    }

    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setBackgroundDrawable(new ColorDrawable());
    window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    WindowManager.LayoutParams params = window.getAttributes();
    params.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL;
    params.x = 0;
    params.y = 0;
    params.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;
    params.windowAnimations = R.style.NoAnimationWindow;

    window.setAttributes(params);
    window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnShowListener(this);
}
 
Example 8
Source File: TimeDateDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
/**
 *
 * @param savedInstanceState a bundle containing previously saved dialog state
 * @return a dialog instance ready to be shown
 */
@SuppressWarnings({"deprecation","RestrictedApi"})
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onDialogShow);
    return dialog;
}
 
Example 9
Source File: LocationConfigDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param savedInstanceState a Bundle containing previously saved dialog state
 * @return an AlertDialog ready for display
 */
@SuppressWarnings({"deprecation","RestrictedApi"})
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onDialogShow);
    return dialog;
}
 
Example 10
Source File: TimeZoneDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"deprecation","RestrictedApi"})
@NonNull @Override
public Dialog onCreateDialog(final Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onDialogShow);
    return dialog;
}
 
Example 11
Source File: MoonDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onShowListener);
    return dialog;
}
 
Example 12
Source File: LightMapDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onShowDialogListener);
    return dialog;
}
 
Example 13
Source File: WorldMapDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@NonNull @Override
public Dialog onCreateDialog(Bundle savedState)
{
    Dialog dialog = super.onCreateDialog(savedState);
    dialog.setOnShowListener(onShowDialogListener);
    expandSheet(dialog);
    return dialog;
}
 
Example 14
Source File: EquinoxDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onShowListener);
    return dialog;
}
 
Example 15
Source File: AbstractMyTracksDialogFragment.java    From mytracks with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  final Dialog dialog = createDialog();
  dialog.setOnShowListener(new DialogInterface.OnShowListener() {

      @Override
    public void onShow(DialogInterface dialogInterface) {
      DialogUtils.setDialogTitleDivider(getActivity(), dialog);
    }
  });
  return dialog;
}
 
Example 16
Source File: CitySearchBottomSheetDialogFragment.java    From Travel-Mate with MIT License 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);

    dialog.setOnShowListener(dialog1 -> {
        View bottomSheet = ((BottomSheetDialog) dialog1)
                .findViewById(android.support.design.R.id.design_bottom_sheet);

        BottomSheetBehavior.from(bottomSheet)
                .setPeekHeight(Resources.getSystem().getDisplayMetrics().heightPixels);
    });

    return dialog;
}
 
Example 17
Source File: FullScreenUtil.java    From mirror with Apache License 2.0 5 votes vote down vote up
public static void onResume(Dialog dialog) {
    View decorView = dialog.getWindow().getDecorView();
    dialog.getWindow().setFlags(FLAG_NOT_FOCUSABLE, FLAG_NOT_FOCUSABLE);
    dialog.setOnShowListener(d -> dialog.getWindow().clearFlags(FLAG_NOT_FOCUSABLE));
    hideSystemUI(decorView);
    decorView.setOnSystemUiVisibilityChangeListener(visibility -> {
        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
            hideSystemUI(decorView);
        }
    });
}
 
Example 18
Source File: BaseDialogFragment.java    From mvvm-template with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    if (!PrefGetter.isAppAnimationDisabled() && !(this instanceof ProgressDialogFragment)) {
        dialog.setOnShowListener(dialogInterface -> AnimHelper.revealDialog(dialog,
                getResources().getInteger(android.R.integer.config_longAnimTime)));
    }
    return dialog;
}
 
Example 19
Source File: CardImageZoomDialog.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setOnShowListener(dialogInterface -> {
        Window window = dialog.getWindow();
        if (window != null)
            window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    });
    return dialog;
}
 
Example 20
Source File: BaseDialogFragment.java    From android-styled-dialogs with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int theme = resolveTheme();
    Dialog dialog = new Dialog(getActivity(), theme);

    Bundle args = getArguments();
    if (args != null) {
        dialog.setCanceledOnTouchOutside(
                args.getBoolean(BaseDialogBuilder.ARG_CANCELABLE_ON_TOUCH_OUTSIDE));
    }
    dialog.setOnShowListener(this);
    return dialog;
}