Example usage for android.graphics Point set

List of usage examples for android.graphics Point set

Introduction

In this page you can find the example usage for android.graphics Point set.

Prototype

public void set(int x, int y) 

Source Link

Document

Set the point's x and y coordinates

Usage

From source file:Main.java

public static Point getScreenSize(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    size.set(display.getWidth(), display.getHeight());
    return size;/*from   w ww  . j a  v  a 2s. c o  m*/
}

From source file:Main.java

public static Point getScreenResolution(Activity activity) {
    // get the layout width/height
    DisplayMetrics dm = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    // create point
    Point p = new Point();
    p.set(dm.widthPixels, dm.heightPixels);

    return p;/*from   w  w  w .  j  a v  a  2s.c o m*/
}

From source file:Main.java

public static Point getScreenResolution(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point screenResolution = new Point();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
        display.getSize(screenResolution);
    } else {/* w w w.ja  v  a 2s . c  o  m*/
        screenResolution.set(display.getWidth(), display.getHeight());
    }
    return screenResolution;
}

From source file:Main.java

public static Point getScreenResolution(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point screenResolution = new Point();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
        display.getSize(screenResolution);
    } else {//from  w ww  .  j  a  v  a 2  s  .c  o m
        screenResolution.set(display.getWidth(), display.getHeight());
    }

    return screenResolution;
}

From source file:Main.java

public static Point getScreenSize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    Display display = wm.getDefaultDisplay();

    Point size = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(size);//from  ww w. j  a  v a2  s. co m
    } else {
        size.set(display.getWidth(), display.getHeight());
    }

    return size;
}

From source file:Main.java

public static void decodeSize(ContentResolver contentResolver, Uri uri, Point out) throws IOException {
    Options opts = new Options();
    opts.inJustDecodeBounds = true;/*  w  w w . j  ava2 s . c  o m*/

    BitmapFactory.decodeStream(contentResolver.openInputStream(uri), null, opts);

    out.set(opts.outWidth, opts.outHeight);
}

From source file:Main.java

@SuppressWarnings("deprecation")
private static Point getDefaultDisplaySize(Activity activity, Point size) {
    Display d = activity.getWindowManager().getDefaultDisplay();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        d.getSize(size);// w  w w .  j a v  a 2 s  .com
    } else {
        size.set(d.getWidth(), d.getHeight());
    }
    return size;
}

From source file:Main.java

/**
 * Gets the screen size in pixels in a backwards compatible way
 *
 * @param caller        Activity calling; needed to get access to the {@link android.view.WindowManager}
 * @return              Size in pixels of the screen, or default {@link Point} if caller is null
 *//*from  www. j a  v a2s .  c  o m*/
public static Point getScreenSize(Activity caller) {
    Point size = new Point();
    if (caller != null) {
        Display display = caller.getWindowManager().getDefaultDisplay();
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
            display.getSize(size);
        } else {
            size.set(display.getWidth(), display.getHeight());
        }
    }
    return size;
}

From source file:Main.java

/**
 * <p>/*w  ww. j a v  a  2s. c om*/
 * This method takes in the WindowManager and returns the Screen Dimensions in pixels.</br></br>
 * </p>
 * <p>To get width (getWindowDisplaySize(wm).x) or height (getWindowDisplaySize(wm).y)</p>
 *
 * @return WindowDisplaySize
 */
public static Point getWindowDisplaySize(WindowManager wm) {
    Display display;
    Point WindowDisplaySize = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        display = wm.getDefaultDisplay();
        display.getSize(WindowDisplaySize);
    } else {
        DisplayMetrics displaymetrics = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(displaymetrics);
        int height = displaymetrics.heightPixels;
        int width = displaymetrics.widthPixels;
        WindowDisplaySize.set(width, height);
    }
    return WindowDisplaySize;
}

From source file:org.kontalk.util.SystemUtils.java

@SuppressWarnings("deprecation")
public static Point getDisplaySize(Context context) {
    Point displaySize = null;
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    if (display != null) {
        displaySize = new Point();
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
            displaySize.set(display.getWidth(), display.getHeight());
        } else {/*from  w  w w. j  ava2s.c  o m*/
            display.getSize(displaySize);
        }
    }

    return displaySize;
}