当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.ORIENTATION_UNDEFINED属性代码示例

本文整理汇总了Java中android.content.res.Configuration.ORIENTATION_UNDEFINED属性的典型用法代码示例。如果您正苦于以下问题:Java Configuration.ORIENTATION_UNDEFINED属性的具体用法?Java Configuration.ORIENTATION_UNDEFINED怎么用?Java Configuration.ORIENTATION_UNDEFINED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.res.Configuration的用法示例。


在下文中一共展示了Configuration.ORIENTATION_UNDEFINED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOrientation

/**
 * Returns the current device orientation.
 */
static String getOrientation(Context context) {
    int orientation = context.getResources().getConfiguration().orientation;
    switch(orientation)
    {
        case  Configuration.ORIENTATION_LANDSCAPE:
            return "Landscape";
        case Configuration.ORIENTATION_PORTRAIT:
            return "Portrait";
        case Configuration.ORIENTATION_SQUARE:
            return "Square";
        case Configuration.ORIENTATION_UNDEFINED:
            return "Unknown";
        default:
            return null;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:CrashDetails.java

示例2: drawResizedBitmap

private void drawResizedBitmap(final Bitmap src, final Bitmap dst) {

        Display getOrient = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        int orientation = Configuration.ORIENTATION_UNDEFINED;
        Point point = new Point();
        getOrient.getSize(point);
        int screen_width = point.x;
        int screen_height = point.y;
        Log.d(TAG, String.format("screen size (%d,%d)", screen_width, screen_height));
        if (screen_width < screen_height) {
            orientation = Configuration.ORIENTATION_PORTRAIT;
            mScreenRotation = -90;
        } else {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
            mScreenRotation = 0;
        }

        Assert.assertEquals(dst.getWidth(), dst.getHeight());
        final float minDim = Math.min(src.getWidth(), src.getHeight());

        final Matrix matrix = new Matrix();

        // We only want the center square out of the original rectangle.
        final float translateX = -Math.max(0, (src.getWidth() - minDim) / 2);
        final float translateY = -Math.max(0, (src.getHeight() - minDim) / 2);
        matrix.preTranslate(translateX, translateY);

        final float scaleFactor = dst.getHeight() / minDim;
        matrix.postScale(scaleFactor, scaleFactor);

        // Rotate around the center if necessary.
        if (mScreenRotation != 0) {
            matrix.postTranslate(-dst.getWidth() / 2.0f, -dst.getHeight() / 2.0f);
            matrix.postRotate(mScreenRotation);
            matrix.postTranslate(dst.getWidth() / 2.0f, dst.getHeight() / 2.0f);
        }

        final Canvas canvas = new Canvas(dst);
        canvas.drawBitmap(src, matrix, null);
    }
 
开发者ID:gicheonkang,项目名称:fast_face_android,代码行数:40,代码来源:OnGetImageListener.java

示例3: setLockRotation

private void setLockRotation(boolean avpLock) {
    Display display = getWindowManager().getDefaultDisplay();
    int rotation = display.getRotation();
    if (DBG) Log.d(TAG, "rotation status: " + rotation);

    boolean systemLock;
    try {
        systemLock = 1 != Settings.System.getInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION);
    } catch (SettingNotFoundException e) {
        systemLock = false;
    }

    if (DBG) Log.d(TAG, "avpLock: " + avpLock + " systemLock: " + systemLock);
    if (avpLock || systemLock) {
        int tmpOrientation = getResources().getConfiguration().orientation;
        int wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;

        if (tmpOrientation == Configuration.ORIENTATION_LANDSCAPE) {
            if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90)
                wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            else
                wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
            setRequestedOrientation(wantedOrientation);
        }
        else if (tmpOrientation == Configuration.ORIENTATION_PORTRAIT || tmpOrientation == Configuration.ORIENTATION_UNDEFINED) {
            if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90)
                wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            else
                wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
            setRequestedOrientation(wantedOrientation);
        }
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:35,代码来源:PlayerActivity.java


注:本文中的android.content.res.Configuration.ORIENTATION_UNDEFINED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。