Example usage for android.content.res Configuration ORIENTATION_LANDSCAPE

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

Introduction

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

Prototype

int ORIENTATION_LANDSCAPE

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

Click Source Link

Document

Constant for #orientation , value corresponding to the land resource qualifier.

Usage

From source file:Main.java

public static boolean isOrientationPortrait(Activity activity) {

    int orientation = activity.getResources().getConfiguration().orientation;

    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        return false;
    case Configuration.ORIENTATION_PORTRAIT:
        return true;
    }//  w w w .  j ava  2 s  . co m
    return true;
}

From source file:Main.java

public static int calcDesiredSize(Context context, int parentWidth, int parentHeight) {
    int orientation = context.getResources().getConfiguration().orientation;
    int desiredSize = (orientation == Configuration.ORIENTATION_LANDSCAPE) ? parentHeight / 2
            : parentHeight / 3;//www  .  j a va  2 s  . co  m
    return Math.min(desiredSize, parentWidth);
}

From source file:Main.java

public static boolean isInLandscapeMode(@NonNull Context context) {
    boolean isLandscape = false;
    if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        isLandscape = true;/* w  w  w  .ja  v a2  s .c  om*/
    }
    return isLandscape;
}

From source file:Main.java

private static String getOrientation(Context ctx) {
    String orientation = "unknown";

    switch (ctx.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        orientation = "landscape";
        break;// ww w.j ava 2s. c  om
    case Configuration.ORIENTATION_PORTRAIT:
        orientation = "portrait";
        break;
    }

    return orientation;
}

From source file:Main.java

public static boolean isPortrait(Configuration newConfig) {
    if (newConfig != null && newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        return false;
    }/*from  ww  w .  ja v  a  2 s. com*/
    return true;
}

From source file:Main.java

public static void OrientationFix(Activity context, boolean fixOrient) {
    if (fixOrient) {
        int ori = context.getResources().getConfiguration().orientation;
        if (ori == Configuration.ORIENTATION_LANDSCAPE) {
            context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {/*from ww w  . ja v  a2  s  .  c  om*/
            context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    } else {
        context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}

From source file:Main.java

public static String getDisplayOrientation(Context context) {
    String text;/*w w w . j  a v  a  2 s .  c  o m*/

    switch (context.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_PORTRAIT:
        text = "portrait";
        break;
    case Configuration.ORIENTATION_LANDSCAPE:
        text = "landscape";
        break;
    case Configuration.ORIENTATION_SQUARE:
        text = "square";
        break;
    default:
        text = null;
    }
    ;

    return text;
}

From source file:Main.java

/***
 * Check whether the orientation is in landscape or portrait
 *
 * @param context//ww  w. ja  v a 2s  .c om
 * @return boolean
 */
public static boolean isInLandscapeMode(@NonNull Context context) {
    boolean isLandscape = false;
    if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        isLandscape = true;
    }
    return isLandscape;
}

From source file:Main.java

/**
 * Determining the Screen's Size is xLarge and Landscape or not..
 * /*  www  .j  a  v a  2 s . c  om*/
 * @param context
 *            The Application Context.
 * @return Boolean Type.
 */
public static boolean isXLargeAndLandscape(Context context) {
    return isXLarge(context)
            && (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
}

From source file:Main.java

/**
 * Overall orientation of the screen./*  ww  w  .j a v a2 s .c  om*/
 * @param orientation "orientation"
 */
@SuppressWarnings("deprecation")
public static String getOrientationStr(int orientation) {
    switch (orientation) {
    case Configuration.ORIENTATION_UNDEFINED://0
        return "ORIENTATION_UNDEFINED";
    case Configuration.ORIENTATION_PORTRAIT://1
        return "ORIENTATION_PORTRAIT";
    case Configuration.ORIENTATION_LANDSCAPE://2
        return "ORIENTATION_LANDSCAPE";
    case Configuration.ORIENTATION_SQUARE://3
        return "ORIENTATION_SQUARE";
    default:
        return UNKNOWN;
    }
}