Example usage for android.content.res Configuration ORIENTATION_UNDEFINED

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

Introduction

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

Prototype

int ORIENTATION_UNDEFINED

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

Click Source Link

Document

Constant for #orientation : a value indicating that no value has been set.

Usage

From source file:Main.java

public static int getScreenOrientation(Activity activity) {
    Display getOrient = activity.getWindowManager().getDefaultDisplay();
    int orientation = Configuration.ORIENTATION_UNDEFINED;
    if (getOrient.getWidth() == getOrient.getHeight()) {
        orientation = Configuration.ORIENTATION_SQUARE;
    } else {//  ww w.j  a  v a2  s  .  c o  m
        if (getOrient.getWidth() < getOrient.getHeight()) {
            orientation = Configuration.ORIENTATION_PORTRAIT;
        } else {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
        }
    }
    return orientation;
}

From source file:Main.java

/**
 * Overall orientation of the screen.//w ww. jav  a 2  s.c  o m
 * @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;
    }
}

From source file:Main.java

public static int getScreenOrientation(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();

    int orientation = Configuration.ORIENTATION_UNDEFINED;
    if (display.getWidth() == display.getHeight()) {
        orientation = Configuration.ORIENTATION_SQUARE;
    } else {/*from w w  w .j a  v a  2 s . c  o m*/
        if (display.getWidth() < display.getHeight()) {
            orientation = Configuration.ORIENTATION_PORTRAIT;
        } else {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
        }
    }
    return orientation;
}

From source file:Main.java

public static int getOrientation(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display getOrient = windowManager.getDefaultDisplay();
    int orientation = Configuration.ORIENTATION_UNDEFINED;
    if (getOrient.getWidth() == getOrient.getHeight()) {
        orientation = Configuration.ORIENTATION_SQUARE;
    } else {//from  w w w  .j av  a  2  s.co m
        if (getOrient.getWidth() < getOrient.getHeight()) {
            orientation = Configuration.ORIENTATION_PORTRAIT;
        } else {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
        }
    }
    return orientation;
}

From source file:Main.java

public static int getScreenOrientation(Context context) {
    Display display = getDefaultDisplay(context);
    int orientation = Configuration.ORIENTATION_UNDEFINED;
    if (display.getWidth() == display.getHeight())
        orientation = Configuration.ORIENTATION_SQUARE;
    else {//from  w w w .j a  v  a 2s  . c  o  m
        if (display.getWidth() < display.getHeight())
            orientation = Configuration.ORIENTATION_PORTRAIT;
        else
            orientation = Configuration.ORIENTATION_LANDSCAPE;
    }

    return orientation;
}

From source file:MainActivity.java

public void checkOrientation(View view) {
    int orientation = getResources().getConfiguration().orientation;
    switch (orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        Toast.makeText(MainActivity.this, "ORIENTATION_LANDSCAPE", Toast.LENGTH_SHORT).show();
        break;//  w w w .java  2s .  com
    case Configuration.ORIENTATION_PORTRAIT:
        Toast.makeText(MainActivity.this, "ORIENTATION_PORTRAIT", Toast.LENGTH_SHORT).show();
        break;
    case Configuration.ORIENTATION_UNDEFINED:
        Toast.makeText(MainActivity.this, "ORIENTATION_UNDEFINED", Toast.LENGTH_SHORT).show();
        break;
    }
}

From source file:Main.java

public static int getSurfaceOrientation(Activity activity) {

    // Sanity check:
    if (activity == null) {
        return -1; // invalid value
    }/*from   ww w.j av a2s. c o m*/

    Configuration config = activity.getResources().getConfiguration();
    Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();

    int displayRotation;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        displayRotation = display.getRotation(); // only available from Froyo
    } else {
        displayRotation = display.getOrientation();
    }

    int activityOrientation = SCREEN_ORIENTATION_UNKNOWN;

    switch (config.orientation) {
    case Configuration.ORIENTATION_PORTRAIT:
    case Configuration.ORIENTATION_SQUARE:
        activityOrientation = ((displayRotation == Surface.ROTATION_0
                || displayRotation == Surface.ROTATION_270) ? SCREEN_ORIENTATION_PORTRAIT
                        : SCREEN_ORIENTATION_PORTRAITUPSIDEDOWN);
        break;

    case Configuration.ORIENTATION_LANDSCAPE:
        activityOrientation = ((displayRotation == Surface.ROTATION_0 || displayRotation == Surface.ROTATION_90)
                ? SCREEN_ORIENTATION_LANDSCAPELEFT
                : SCREEN_ORIENTATION_LANDSCAPERIGHT);
        break;

    case Configuration.ORIENTATION_UNDEFINED:
    default:
        break;
    }

    return activityOrientation;
}

From source file:com.jt.fragutils.FragmentScreenViewHelper.java

/**
 * Call this method from onResume to check whether this is a new screen view (first time load
 * or return from background - Not an orientation change)
 *
 * @param context Fragment/*from  ww  w .  ja v a2  s  .co  m*/
 * @return whether this is a new screen view (not an orientation change)
 */
public boolean isNewScreenView(Fragment context) {
    boolean bNewView = true;

    int iNewOrientation = context.getResources().getConfiguration().orientation;
    if ((mOrientation != Configuration.ORIENTATION_UNDEFINED) && (iNewOrientation != mOrientation)) {
        bNewView = false;
    }

    // Set the new orientation
    mOrientation = iNewOrientation;

    return bNewView;
}

From source file:com.mruddy.devdataviewer.DevDataListFragment.java

@SuppressLint("InlinedApi")
private static void initMaps() {
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_LOW, "LDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_MEDIUM, "MDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_HIGH, "HDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XHIGH, "XHDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXHIGH, "XXHDPI");
    DevDataListFragment.DENSITY_BUCKETS.append(DisplayMetrics.DENSITY_XXXHIGH, "XXXHDPI");
    DevDataListFragment.ROTATION.append(Surface.ROTATION_0, "0");
    DevDataListFragment.ROTATION.append(Surface.ROTATION_90, "90");
    DevDataListFragment.ROTATION.append(Surface.ROTATION_180, "180");
    DevDataListFragment.ROTATION.append(Surface.ROTATION_270, "270");
    DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_UNDEFINED, "undefined");
    DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_PORTRAIT, "portrait");
    DevDataListFragment.ORIENTATION.append(Configuration.ORIENTATION_LANDSCAPE, "landscape");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_UNDEFINED, "undefined");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_SMALL, "small");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_NORMAL, "normal");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_LARGE, "large");
    DevDataListFragment.SCREEN_SIZE_BUCKETS.append(Configuration.SCREENLAYOUT_SIZE_XLARGE, "xlarge");
}

From source file:com.manning.androidhacks.hack014.MainActivity.java

private void setVideoViewPosition() {
    switch (getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_LANDSCAPE: {
        mPortraitContent.setVisibility(View.GONE);

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);

        params.addRule(RelativeLayout.CENTER_IN_PARENT);
        mVideoView.setLayoutParams(params);
        break;/* w  w w .j a  v a  2s  .  c  o  m*/
    }

    case Configuration.ORIENTATION_SQUARE:
    case Configuration.ORIENTATION_UNDEFINED:
    case Configuration.ORIENTATION_PORTRAIT:
    default: {

        mPortraitContent.setVisibility(View.VISIBLE);

        int[] locationArray = new int[2];
        mPortraitPosition.getLocationOnScreen(locationArray);

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(mPortraitPosition.getWidth(),
                mPortraitPosition.getHeight());

        params.leftMargin = locationArray[0];
        params.topMargin = locationArray[1];

        mVideoView.setLayoutParams(params);

        break;
    }
    }
}