Search in sources :

Example 31 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 32 with Display

use of android.view.Display in project grafika by google.

the class MiscUtils method getDisplayRefreshNsec.

/**
     * Obtains the approximate refresh time, in nanoseconds, of the default display associated
     * with the activity.
     * <p>
     * The actual refresh rate can vary slightly (e.g. 58-62fps on a 60fps device).
     */
public static long getDisplayRefreshNsec(Activity activity) {
    Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    double displayFps = display.getRefreshRate();
    long refreshNs = Math.round(1000000000L / displayFps);
    Log.d(TAG, "refresh rate is " + displayFps + " fps --> " + refreshNs + " ns");
    return refreshNs;
}
Also used : Display(android.view.Display) WindowManager(android.view.WindowManager)

Example 33 with Display

use of android.view.Display in project QuickReturn by lawloretienne.

the class QuickReturnUtils method px2dp.

public static int px2dp(Context context, int px) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics displaymetrics = new DisplayMetrics();
    display.getMetrics(displaymetrics);
    return (int) (px / displaymetrics.density + 0.5f);
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 34 with Display

use of android.view.Display in project QuickReturn by lawloretienne.

the class QuickReturnUtils method dp2px.

public static int dp2px(Context context, int dp) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics displaymetrics = new DisplayMetrics();
    display.getMetrics(displaymetrics);
    return (int) (dp * displaymetrics.density + 0.5f);
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 35 with Display

use of android.view.Display in project LiveSDK-for-Android by liveservices.

the class SkyDriveActivity method extractScaledBitmap.

/**
     * Extract a photo from SkyDrive and creates a scaled bitmap according to the device resolution, this is needed to
     * prevent memory over-allocation that can cause some devices to crash when opening high-resolution pictures
     *
     * Note: this method should not be used for downloading photos, only for displaying photos on-screen
     *
     * @param photo The source photo to download
     * @param imageStream The stream that contains the photo
     * @return Scaled bitmap representation of the photo
     * @see http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object/823966#823966
     */
private Bitmap extractScaledBitmap(SkyDrivePhoto photo, InputStream imageStream) {
    Display display = getWindowManager().getDefaultDisplay();
    int IMAGE_MAX_SIZE = Math.max(display.getWidth(), display.getHeight());
    int scale = 1;
    if (photo.getHeight() > IMAGE_MAX_SIZE || photo.getWidth() > IMAGE_MAX_SIZE) {
        scale = (int) Math.pow(2, (int) Math.ceil(Math.log(IMAGE_MAX_SIZE / (double) Math.max(photo.getHeight(), photo.getWidth())) / Math.log(0.5)));
    }
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPurgeable = true;
    options.inSampleSize = scale;
    return BitmapFactory.decodeStream(imageStream, (Rect) null, options);
}
Also used : BitmapFactory(android.graphics.BitmapFactory) Display(android.view.Display)

Aggregations

Display (android.view.Display)478 Point (android.graphics.Point)231 WindowManager (android.view.WindowManager)201 DisplayMetrics (android.util.DisplayMetrics)78 SuppressLint (android.annotation.SuppressLint)29 Resources (android.content.res.Resources)25 Bitmap (android.graphics.Bitmap)25 LinearLayout (android.widget.LinearLayout)25 Rect (android.graphics.Rect)23 View (android.view.View)23 Method (java.lang.reflect.Method)23 RemoteException (android.os.RemoteException)22 Canvas (android.graphics.Canvas)21 VirtualDisplay (android.hardware.display.VirtualDisplay)20 TextView (android.widget.TextView)18 Dialog (android.app.Dialog)17 Camera (android.hardware.Camera)17 Intent (android.content.Intent)16 ViewGroup (android.view.ViewGroup)16 Context (android.content.Context)15