isFloating ( )源码实例Demo

android.view.Window#isFloating ( )源码实例Demo

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

源代码1 项目: AndroidNavigation   文件: AwesomeFragment.java
@Override
@NonNull
public LayoutInflater onGetLayoutInflater(@Nullable Bundle savedInstanceState) {
    inflateStyle();

    if (!getShowsDialog()) {
        return super.onGetLayoutInflater(savedInstanceState);
    }

    setStyle(STYLE_NORMAL, R.style.Theme_Nav_FullScreenDialog);

    super.onGetLayoutInflater(savedInstanceState);
    LayoutInflater layoutInflater = requireActivity().getLayoutInflater();
    Window window = getWindow();
    boolean isFloating = window != null && window.isFloating();
    if (getShowsDialog() && !isFloating) {
        layoutInflater = new DialogLayoutInflater(requireContext(), layoutInflater,
                () -> {
                    if (isCancelable()) {
                        hideDialog();
                    }
                });
    }

    return layoutInflater;
}
 
源代码2 项目: android-lockpattern   文件: UI.java
/**
 * Uses a fixed size for {@code dialogWindow} in large screens.
 * 
 * @param dialogWindow
 *            the window <i>of the dialog</i>.
 */
public static void adjustDialogSizeForLargeScreens(Window dialogWindow) {
    if (DEBUG)
        Log.d(CLASSNAME, "adjustDialogSizeForLargeScreens()");

    if (!dialogWindow.isFloating())
        return;

    final ScreenSize screenSize = ScreenSize.getCurrent(dialogWindow
            .getContext());
    switch (screenSize) {
    case LARGE:
    case XLARGE:
        break;
    default:
        return;
    }

    final DisplayMetrics metrics = dialogWindow.getContext().getResources()
            .getDisplayMetrics();
    final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;

    int width = metrics.widthPixels;// dialogWindow.getDecorView().getWidth();
    int height = metrics.heightPixels;// dialogWindow.getDecorView().getHeight();
    if (DEBUG)
        Log.d(CLASSNAME,
                String.format("width = %,d | height = %,d", width, height));

    width = (int) (width * (isPortrait ? screenSize.fixedWidthMinor
            : screenSize.fixedWidthMajor));
    height = (int) (height * (isPortrait ? screenSize.fixedHeightMajor
            : screenSize.fixedHeightMinor));

    if (DEBUG)
        Log.d(CLASSNAME, String.format(
                "NEW >>> width = %,d | height = %,d", width, height));
    dialogWindow.setLayout(width, height);
}
 
源代码3 项目: android-lockpattern   文件: UI.java
/**
 * Uses a fixed size for {@code dialogWindow} in large screens.
 * 
 * @param dialogWindow
 *            the window <i>of the dialog</i>.
 */
public static void adjustDialogSizeForLargeScreens(Window dialogWindow) {
    if (BuildConfig.DEBUG)
        Log.d(CLASSNAME, "adjustDialogSizeForLargeScreens()");

    if (!dialogWindow.isFloating())
        return;

    final ScreenSize screenSize = ScreenSize.getCurrent(dialogWindow
            .getContext());
    switch (screenSize) {
    case LARGE:
    case XLARGE:
        break;
    default:
        return;
    }

    final DisplayMetrics metrics = dialogWindow.getContext().getResources()
            .getDisplayMetrics();
    final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;

    int width = metrics.widthPixels;// dialogWindow.getDecorView().getWidth();
    int height = metrics.heightPixels;// dialogWindow.getDecorView().getHeight();
    if (BuildConfig.DEBUG)
        Log.d(CLASSNAME,
                String.format("width = %,d | height = %,d", width, height));

    width = (int) (width * (isPortrait ? screenSize.fixedWidthMinor
            : screenSize.fixedWidthMajor));
    height = (int) (height * (isPortrait ? screenSize.fixedHeightMajor
            : screenSize.fixedHeightMinor));

    if (BuildConfig.DEBUG)
        Log.d(CLASSNAME, String.format(
                "NEW >>> width = %,d | height = %,d", width, height));
    dialogWindow.setLayout(width, height);
}
 
源代码4 项目: Pi-Locker   文件: UI.java
/**
 * Uses a fixed size for {@code dialogWindow} in large screens.
 * 
 * @param dialogWindow
 *            the window <i>of the dialog</i>.
 */
public static void adjustDialogSizeForLargeScreen(final Window dialogWindow) {
    if (BuildConfig.DEBUG)
        Log.d(CLASSNAME, "adjustDialogSizeForLargeScreen()");
    if (dialogWindow.isFloating()
            && dialogWindow.getContext().getResources()
                    .getBoolean(R.bool.alp_is_large_screen)) {
        final DisplayMetrics metrics = dialogWindow.getContext()
                .getResources().getDisplayMetrics();
        final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;

        int width = metrics.widthPixels;// dialogWindow.getDecorView().getWidth();
        int height = metrics.heightPixels;// dialogWindow.getDecorView().getHeight();
        if (BuildConfig.DEBUG)
            Log.d(CLASSNAME, String.format("width = %,d | height = %,d",
                    width, height));
        width = (int) dialogWindow
                .getContext()
                .getResources()
                .getFraction(
                        isPortrait ? R.dimen.aosp_dialog_fixed_width_minor
                                : R.dimen.aosp_dialog_fixed_width_major,
                        width, width);
        height = (int) dialogWindow
                .getContext()
                .getResources()
                .getFraction(
                        isPortrait ? R.dimen.aosp_dialog_fixed_height_major
                                : R.dimen.aosp_dialog_fixed_height_minor,
                        height, height);
        if (BuildConfig.DEBUG)
            Log.d(CLASSNAME, String.format(
                    "NEW >>> width = %,d | height = %,d", width, height));
        dialogWindow.setLayout(width, height);
    }
}