setOnShowListener ( )源码实例Demo

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

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

源代码1 项目: msdkui-android   文件: TravelTimePicker.java
@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;
}
 
源代码2 项目: mvvm-template   文件: BaseBottomSheetDialog.java
@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;
}
 
源代码3 项目: AndroidTabbedDialog   文件: BaseDialogFragment.java
@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;
}
 
@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;
}
 
@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;
}
 
@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;
}
 
源代码7 项目: mvvm-template   文件: BaseDialogFragment.java
@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;
}
 
源代码8 项目: mirror   文件: FullScreenUtil.java
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);
        }
    });
}
 
@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;
}
 
源代码10 项目: mytracks   文件: AbstractMyTracksDialogFragment.java
@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;
}
 
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);

}
 
源代码12 项目: SuntimesWidget   文件: EquinoxDialog.java
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onShowListener);
    return dialog;
}
 
源代码13 项目: SuntimesWidget   文件: WorldMapDialog.java
@NonNull @Override
public Dialog onCreateDialog(Bundle savedState)
{
    Dialog dialog = super.onCreateDialog(savedState);
    dialog.setOnShowListener(onShowDialogListener);
    expandSheet(dialog);
    return dialog;
}
 
源代码14 项目: SuntimesWidget   文件: LightMapDialog.java
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onShowDialogListener);
    return dialog;
}
 
源代码15 项目: SuntimesWidget   文件: MoonDialog.java
@NonNull @Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onShowListener);
    return dialog;
}
 
源代码16 项目: SuntimesWidget   文件: TimeZoneDialog.java
@SuppressWarnings({"deprecation","RestrictedApi"})
@NonNull @Override
public Dialog onCreateDialog(final Bundle savedInstanceState)
{
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(onDialogShow);
    return dialog;
}
 
源代码17 项目: SuntimesWidget   文件: LocationConfigDialog.java
/**
 * @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;
}
 
源代码18 项目: SuntimesWidget   文件: TimeDateDialog.java
/**
 *
 * @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;
}
 
源代码19 项目: Material-SearchView   文件: SearchView.java
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);
}
 
源代码20 项目: fdroidclient   文件: ShareChooserDialog.java
@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;
}