Example usage for android.content.res Configuration SCREEN_HEIGHT_DP_UNDEFINED

List of usage examples for android.content.res Configuration SCREEN_HEIGHT_DP_UNDEFINED

Introduction

In this page you can find the example usage for android.content.res Configuration SCREEN_HEIGHT_DP_UNDEFINED.

Prototype

int SCREEN_HEIGHT_DP_UNDEFINED

To view the source code for android.content.res Configuration SCREEN_HEIGHT_DP_UNDEFINED.

Click Source Link

Document

Default value for #screenHeightDp indicating that no width has been specified.

Usage

From source file:Main.java

/**
 * The current height of the available screen space, in dp units.
 * @param screen_height_dp "screenHeightDp"
 *//*from www.j  a va  2 s  .com*/
public static String getScreenHeightDpStr(int screen_height_dp) {
    switch (screen_height_dp) {
    case Configuration.SCREEN_HEIGHT_DP_UNDEFINED://0
        return "SCREEN_HEIGHT_DP_UNDEFINED";
    default:
        return UNKNOWN;
    }
}

From source file:kr.wdream.storyshop.AndroidUtilities.java

public static void checkDisplaySize(Context context, Configuration newConfiguration) {
    try {/*from w  w w. j a v  a 2  s.  c o  m*/
        density = context.getResources().getDisplayMetrics().density;
        Configuration configuration = newConfiguration;
        if (configuration == null) {
            configuration = context.getResources().getConfiguration();
        }
        usingHardwareInput = configuration.keyboard != Configuration.KEYBOARD_NOKEYS
                && configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
        WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        if (manager != null) {
            Display display = manager.getDefaultDisplay();
            if (display != null) {
                display.getMetrics(displayMetrics);
                display.getSize(displaySize);
            }
        }
        if (configuration.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) {
            int newSize = (int) Math.ceil(configuration.screenWidthDp * density);
            if (Math.abs(displaySize.x - newSize) > 3) {
                displaySize.x = newSize;
            }
        }
        if (configuration.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) {
            int newSize = (int) Math.ceil(configuration.screenHeightDp * density);
            if (Math.abs(displaySize.y - newSize) > 3) {
                displaySize.y = newSize;
            }
        }
        FileLog.e("tmessages", "display size = " + displaySize.x + " " + displaySize.y + " "
                + displayMetrics.xdpi + "x" + displayMetrics.ydpi);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}

From source file:com.ferdi2005.secondgram.AndroidUtilities.java

public static void checkDisplaySize(Context context, Configuration newConfiguration) {
    try {/*ww  w .ja va2  s.  c  o  m*/
        density = context.getResources().getDisplayMetrics().density;
        Configuration configuration = newConfiguration;
        if (configuration == null) {
            configuration = context.getResources().getConfiguration();
        }
        usingHardwareInput = configuration.keyboard != Configuration.KEYBOARD_NOKEYS
                && configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
        WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        if (manager != null) {
            Display display = manager.getDefaultDisplay();
            if (display != null) {
                display.getMetrics(displayMetrics);
                display.getSize(displaySize);
            }
        }
        if (configuration.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) {
            int newSize = (int) Math.ceil(configuration.screenWidthDp * density);
            if (Math.abs(displaySize.x - newSize) > 3) {
                displaySize.x = newSize;
            }
        }
        if (configuration.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) {
            int newSize = (int) Math.ceil(configuration.screenHeightDp * density);
            if (Math.abs(displaySize.y - newSize) > 3) {
                displaySize.y = newSize;
            }
        }
        FileLog.e("display size = " + displaySize.x + " " + displaySize.y + " " + displayMetrics.xdpi + "x"
                + displayMetrics.ydpi);
    } catch (Exception e) {
        FileLog.e(e);
    }
}