Example usage for android.content.res Configuration SCREEN_WIDTH_DP_UNDEFINED

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

Introduction

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

Prototype

int SCREEN_WIDTH_DP_UNDEFINED

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

Click Source Link

Document

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

Usage

From source file:Main.java

/**
 * The current width of the available screen space, in dp units.
 * @param screen_width_dp "screenWidthDp"
 *//* www .  j  a v a  2  s  . co m*/
public static String getScreenWidthDpStr(int screen_width_dp) {
    switch (screen_width_dp) {
    case Configuration.SCREEN_WIDTH_DP_UNDEFINED://0
        return "SCREEN_WIDTH_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.  ja  v  a  2 s . c  om
        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 {/*w w w  .  ja v  a 2s. 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);
    }
}