Example usage for android.graphics Point Point

List of usage examples for android.graphics Point Point

Introduction

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

Prototype

public Point() 

Source Link

Usage

From source file:com.tencent.wetest.common.util.DeviceUtil.java

/**
 * ??// ww w .  j  a  va 2 s.co m
 * @param cx 
 * @return ? ( width x height )
 */

public static String getDisplayMetrics(Context cx) {

    WindowManager mWindowManager = (WindowManager) cx.getSystemService(Context.WINDOW_SERVICE);
    Display display = mWindowManager.getDefaultDisplay();
    DisplayMetrics metric = new DisplayMetrics();

    Point size = new Point();

    String str = "";

    try {

        if (Build.VERSION.SDK_INT >= 11) {

            display.getRealSize(size);

            str += String.valueOf(size.x) + " x " + String.valueOf(size.y);

        } else {

            Method method = Class.forName("android.view.Display").getMethod("getRealMetrics",
                    DisplayMetrics.class);
            method.invoke(display, metric);

            str += String.valueOf(metric.widthPixels) + " x " + String.valueOf(metric.heightPixels);

        }

    } catch (Exception e) {

        display.getMetrics(metric);
        str += String.valueOf(metric.widthPixels) + " x " + String.valueOf(metric.heightPixels);
        Logger.error("getDeviceRealMetric Exception : " + e.toString());

    }

    return str;

}

From source file:cn.bingoogolapple.refreshlayout.BGAStickinessRefreshView.java

private void initBounds() {
    mTopBound = new RectF();
    mBottomBound = new RectF();
    mRotateDrawableBound = new Rect();
    mCenterPoint = new Point();
}

From source file:com.bobomee.android.common.util.ScreenUtil.java

/**
 * get the width of screen **/*from w  w  w  .ja v a  2s  . co m*/
 */
public static int getScreenW(Context ctx) {
    int w = 0;
    if (Build.VERSION.SDK_INT > 13) {
        Point p = new Point();
        ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getSize(p);
        w = p.x;
    } else {
        w = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
    }
    return w;
}

From source file:io.github.importre.android.chromeadb.ChromeAdbService.java

@SuppressLint("NewApi")
private void setCursorPosToCenter() {
    if (mWindowManager == null || mCursorImage == null) {
        return;// w  w  w  .  j  ava 2  s .  co m
    }

    Display display = mWindowManager.getDefaultDisplay();
    int x, y;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Point size = new Point();
        display.getSize(size);
        x = size.x;
        y = size.y;
    } else {
        x = display.getWidth();
        y = display.getHeight();
    }

    move(x >> 1, y >> 1);
}

From source file:com.orange.labs.sdk.RestUtils.java

public RestUtils(Context context) {
    // Create Volley Request Queue thanks to context
    mRequestQueue = Volley.newRequestQueue(context);

    // Fix maxWidth & maxHeight of screen
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/* ww w . jav a 2 s  .  c o m*/
    maxWidth = size.x;
    maxHeight = size.y;
}

From source file:com.dm.material.dashboard.candybar.helpers.ViewHelper.java

private static Point getAppUsableScreenSize(@NonNull Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from   www . jav a 2s  . c  om
    return size;
}

From source file:com.example.examplescroll.MainActivity.java

public RemoteImageLoader getFullRemoteImageLoader() {
    if (mFullRemoteImageLoader != null) {
        return mFullRemoteImageLoader;
    }/*from  www. j av a 2 s . c  om*/

    Point displaySize = new Point();
    getDisplaySize(displaySize);
    mFullRemoteImageLoader = new RemoteImageLoader(this, getDiskCache(), getMemoryCache(), displaySize.y / 2,
            displaySize.x / 2);
    return mFullRemoteImageLoader;
}

From source file:com.fallahpoor.infocenter.fragments.ScreenFragment.java

private ArrayList<String> getSubItemsArrayList() {

    ArrayList<String> subItems = new ArrayList<>();
    Point displaySize = new Point();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    Display display = getActivity().getWindowManager().getDefaultDisplay();

    display.getSize(displaySize);/*from  ww w  .  ja v a 2s . co  m*/
    display.getMetrics(displayMetrics);

    subItems.add(getDisplaySize(displaySize));
    subItems.add(getOrientation(displaySize));
    subItems.add(getRefreshRate(display));
    subItems.add(getDpi(displayMetrics));
    subItems.add(getHorizontalDpi(displayMetrics));
    subItems.add(getVerticalDpi(displayMetrics));

    return subItems;

}

From source file:com.klinker.android.launcher.addons.settings.page_picker.PagePickerActivity.java

public void setUpWindow() {
    //requestWindowFeature(Window.FEATURE_ACTION_BAR);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
            WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    // Params for the window.
    // You can easily set the alpha and the dim behind the window from here
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.alpha = 1.0f; // lower than one makes it more transparent
    params.dimAmount = .87f; // set it higher if you want to dim behind the window
    getWindow().setAttributes(params);/*ww  w  .  j  a v  a  2 s .c o m*/

    // Gets the display size so that you can set the window to a percent of that
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    // You could also easily used an integer value from the shared preferences to set the percent
    if (height > width) {
        getWindow().setLayout((int) (width * .85), (int) (height * .7));
    } else {
        getWindow().setLayout((int) (width * .5), (int) (height * .8));
    }
}

From source file:com.dm.material.dashboard.candybar.helpers.ViewHelper.java

public static Point getRealScreenSize(@NonNull Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        display.getRealSize(size);// ww w.  j  a  v a  2  s.co  m
    } else {
        try {
            size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
            size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
        } catch (Exception e) {
            size.x = display.getWidth();
            size.y = display.getHeight();
        }
    }
    return size;
}