Example usage for android.view Surface ROTATION_0

List of usage examples for android.view Surface ROTATION_0

Introduction

In this page you can find the example usage for android.view Surface ROTATION_0.

Prototype

int ROTATION_0

To view the source code for android.view Surface ROTATION_0.

Click Source Link

Document

Rotation constant: 0 degree rotation (natural orientation)

Usage

From source file:org.videolan.vlc.gui.video.VideoPlayerActivity.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private int getScreenOrientation() {
    switch (getScreenRotation()) {
    case Surface.ROTATION_0:
        return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    case Surface.ROTATION_90:
        return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    case Surface.ROTATION_180:
        // SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API Level 9+
        return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO
                ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
                : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    case Surface.ROTATION_270:
        // SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API Level 9+
        return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO
                ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
                : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    default:/*ww  w .  j a v a  2 s  . c om*/
        return 0;
    }
}

From source file:com.android.launcher2.Launcher.java

private int mapConfigurationOriActivityInfoOri(int configOri) {
    final Display d = getWindowManager().getDefaultDisplay();
    int naturalOri = Configuration.ORIENTATION_LANDSCAPE;
    switch (d.getRotation()) {
    case Surface.ROTATION_0:
    case Surface.ROTATION_180:
        // We are currently in the same basic orientation as the natural orientation
        naturalOri = configOri;/*  w w  w  .j a va2s  .c o m*/
        break;
    case Surface.ROTATION_90:
    case Surface.ROTATION_270:
        // We are currently in the other basic orientation to the natural orientation
        naturalOri = (configOri == Configuration.ORIENTATION_LANDSCAPE) ? Configuration.ORIENTATION_PORTRAIT
                : Configuration.ORIENTATION_LANDSCAPE;
        break;
    }

    int[] oriMap = { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
            ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,
            ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE };
    // Since the map starts at portrait, we need to offset if this device's natural orientation
    // is landscape.
    int indexOffset = 0;
    if (naturalOri == Configuration.ORIENTATION_LANDSCAPE) {
        indexOffset = 1;
    }
    return oriMap[(d.getRotation() + indexOffset) % 4];
}