Search in sources :

Example 96 with Display

use of android.view.Display in project platform_frameworks_base by android.

the class WallpaperManagerService method getMaximumSizeDimension.

private int getMaximumSizeDimension() {
    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display d = wm.getDefaultDisplay();
    return d.getMaximumSizeDimension();
}
Also used : WindowManager(android.view.WindowManager) IWindowManager(android.view.IWindowManager) Display(android.view.Display)

Example 97 with Display

use of android.view.Display in project libgdx by libgdx.

the class AndroidGraphics method onSurfaceCreated.

@Override
public void onSurfaceCreated(javax.microedition.khronos.opengles.GL10 gl, EGLConfig config) {
    eglContext = ((EGL10) EGLContext.getEGL()).eglGetCurrentContext();
    setupGL(gl);
    logConfig(config);
    updatePpi();
    Mesh.invalidateAllMeshes(app);
    Texture.invalidateAllTextures(app);
    Cubemap.invalidateAllCubemaps(app);
    TextureArray.invalidateAllTextureArrays(app);
    ShaderProgram.invalidateAllShaderPrograms(app);
    FrameBuffer.invalidateAllFrameBuffers(app);
    logManagedCachesStatus();
    Display display = app.getWindowManager().getDefaultDisplay();
    this.width = display.getWidth();
    this.height = display.getHeight();
    this.mean = new WindowedMean(5);
    this.lastFrameTime = System.nanoTime();
    gl.glViewport(0, 0, this.width, this.height);
}
Also used : WindowedMean(com.badlogic.gdx.math.WindowedMean) Display(android.view.Display) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay)

Example 98 with Display

use of android.view.Display in project NoHttp by yanzhenjie.

the class DisplayUtils method initScreen.

/**
     * 初始化屏幕宽度和高度
     */
public static void initScreen(Activity activity) {
    if (isInitialize)
        return;
    isInitialize = true;
    Display display = activity.getWindowManager().getDefaultDisplay();
    DisplayMetrics metric = new DisplayMetrics();
    // 屏幕宽度、高度、密度、缩放因子
    if (VERSION.SDK_INT >= 17) {
        display.getRealMetrics(metric);
    } else {
        try {
            Class<?> clazz = Class.forName("android.view.Display");
            Method method = clazz.getMethod("getRealMetrics", DisplayMetrics.class);
            method.invoke(display, metric);
        } catch (Throwable e) {
            display.getMetrics(metric);
        }
    }
    try {
        // 状态栏高度
        Class<?> clazz = Class.forName("com.android.internal.R$dimen");
        Field field = clazz.getField("status_bar_height");
        int x = Integer.parseInt(field.get(clazz.newInstance()).toString());
        statusBarHeight = activity.getResources().getDimensionPixelSize(x);
    } catch (Throwable e) {
        e.printStackTrace();
        Rect outRect = new Rect();
        activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
        statusBarHeight = outRect.top;
    }
    screenWidth = metric.widthPixels;
    screenHeight = metric.heightPixels;
    screenDpi = metric.densityDpi;
    density = metric.density;
    scaledDensity = metric.scaledDensity;
    if (screenWidth >= 320 && screenWidth < 480) {
        displayType = DISPLAY_SMALL;
    } else if (screenWidth >= 480 && screenWidth < 720) {
        displayType = DISPLAY_MIDDLE;
    } else if (screenWidth >= 720 && screenWidth < 1080) {
        displayType = DISPLAY_LARGE;
    } else {
        displayType = DISPLAY_XLARGE;
    }
}
Also used : Field(java.lang.reflect.Field) Rect(android.graphics.Rect) Method(java.lang.reflect.Method) DisplayMetrics(android.util.DisplayMetrics) Display(android.view.Display)

Example 99 with Display

use of android.view.Display in project TourGuide by worker8.

the class ToolTilMeasureTest method getScreenHeight.

public int getScreenHeight(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.y;
}
Also used : Point(android.graphics.Point) Display(android.view.Display)

Example 100 with Display

use of android.view.Display in project WordPress-Android by wordpress-mobile.

the class StatsUIHelper method isInLandscape.

private static boolean isInLandscape(Activity act) {
    Display display = act.getWindowManager().getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    return (point.y < point.x);
}
Also used : Point(android.graphics.Point) Display(android.view.Display)

Aggregations

Display (android.view.Display)697 Point (android.graphics.Point)356 WindowManager (android.view.WindowManager)349 DisplayMetrics (android.util.DisplayMetrics)126 View (android.view.View)57 TextView (android.widget.TextView)54 LinearLayout (android.widget.LinearLayout)45 SuppressLint (android.annotation.SuppressLint)43 Method (java.lang.reflect.Method)41 ImageView (android.widget.ImageView)39 Bitmap (android.graphics.Bitmap)38 Resources (android.content.res.Resources)36 Intent (android.content.Intent)34 Camera (android.hardware.Camera)31 Context (android.content.Context)26 Rect (android.graphics.Rect)25 IOException (java.io.IOException)24 ViewGroup (android.view.ViewGroup)23 Canvas (android.graphics.Canvas)22 RemoteException (android.os.RemoteException)22