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:net.kevxu.muzei.interfacelift.InterfaceliftMacdropsClient.java

/**
 * Get suitable photo size based on the screen size of phone.
 *
 * @return Dimension Dimension of suitable photo size.
 *//*from   w  w w.j a v a  2s.  c  o m*/
protected Dimension getSuitablePhotoDimension() {
    WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getRealSize(size);
    final int width = size.x;
    final int height = size.y;

    int screenLayout = mContext.getResources().getConfiguration().screenLayout;
    boolean isXlarge = ((screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
    boolean isLarge = ((screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
    final boolean isTablet = isXlarge || isLarge;

    Dimension dimen;

    if (!isTablet) {
        // Wallpaper for phone needs at least [width x 2] x height
        dimen = new Dimension(width * 2, height);
    } else {
        // Wallpaper for tablet needs at least [long edge] x [long edge]
        int longEdge = width > height ? width : height;
        dimen = new Dimension(longEdge, longEdge);
    }

    return dimen;
}

From source file:com.activiti.android.ui.utils.UIUtils.java

/**
 * Retrieve screen dimension.//from   w  w w  .  j  ava  2  s.  c o  m
 *
 * @param activity
 * @return
 */
public static int[] getScreenDimension(Activity activity) {
    int width = 0;
    int height = 0;

    Display display = activity.getWindowManager().getDefaultDisplay();
    if (AndroidVersion.isHCMR2OrAbove()) {
        Point size = new Point();
        display.getSize(size);
        width = size.x;
        height = size.y;
    } else {
        width = display.getWidth(); // deprecated
        height = display.getHeight(); // deprecated
    }

    return new int[] { width, height };
}

From source file:com.pimp.instincts.adapters.GalleryAdapter.java

public GalleryAdapter(Context context, ArrayList<String> imagesList) {
    this.context = context;
    this.imagesList = imagesList;
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from  ww  w  .j a  va2s. c  o  m
    screenWidth = size.x;
}

From source file:com.amazon.android.utils.Helpers.java

/**
 * Returns the screen/display size./*from   ww  w  .  j a v a2s  .com*/
 *
 * @param context The context.
 * @return The display size.
 */
public static Point getDisplaySize(Context context) {

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;
}

From source file:com.example.toolbar.view.MultiViewPager.java

public MultiViewPager(Context context, AttributeSet attrs) {
    super(context, attrs);
    init(context, attrs);//ww w.  ja va  2 s . c om
    size = new Point();
    maxSize = new Point();
}

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

/**
 * get the height of screen */* w w  w  .  j a  va  2 s . c  om*/
 */
public static int getScreenH(Context ctx) {
    int h = 0;
    if (Build.VERSION.SDK_INT > 13) {
        Point p = new Point();
        ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getSize(p);
        h = p.y;
    } else {
        h = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
    }
    return h;
}

From source file:com.itime.team.itime.fragments.QRCodeFragment.java

@NonNull
@Override/* ww w  .  ja  v  a2 s  . c  o m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.fragment_profile_qrcode);
    ImageView imageView = (ImageView) dialog.findViewById(R.id.setting_profile_qrcode_img);

    final Bundle arguments = getArguments();
    if (!arguments.isEmpty()) {
        mUserId = arguments.getString(QRCODE_STRING);
    }

    Bitmap qrCodeBitmap;

    // method1: change a fix dip to pixel
    //final int dim = DensityUtil.dip2px(getContext(), 600);

    // method2: get the display size and scale into 7/8
    // This assumes the view is full screen, which is a good assumption
    WindowManager manager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    Point displaySize = new Point();
    display.getSize(displaySize);
    int width = displaySize.x;
    int height = displaySize.y;
    int smallerDimension = width < height ? width : height;
    final int dim = smallerDimension * 7 / 8;

    try {
        qrCodeBitmap = barcodeEncoder.encodeBitmap(mUserId, BarcodeFormat.QR_CODE, dim, dim);
        imageView.setImageBitmap(qrCodeBitmap);
    } catch (WriterException e) {
        Toast.makeText(getActivity(), "QRCode text can not be empty", Toast.LENGTH_SHORT).show();
    }

    return dialog;
}

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

public MemoryCache getMemoryCache() {
    if (mMemoryCache == null) {
        return mMemoryCache;
    }/* w w  w .  j a  v  a 2 s.c o  m*/

    Point displaySize = new Point();
    getDisplaySize(displaySize);
    int displayMemory = displaySize.x * displaySize.y * MemoryCache.BYTES_PER_PIXEL;
    int cacheSize = NUMBER_OF_SCREENS_IN_MEMORY * displayMemory;
    mMemoryCache = new MemoryCache(cacheSize);
    return mMemoryCache;
}

From source file:com.javielinux.utils.SplitActionBarMenu.java

private void init(FragmentActivity activity) {
    this.activity = activity;
    splitActionBarMenuHeight = activity.getResources().getDimension(R.dimen.actionbar_columns_height);

    Rect rect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);

    try {/*  www .j a  va  2 s  .c  om*/
        Point size = new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(size);
        screenHeight = size.y;
    } catch (NoSuchMethodError e) {
        screenHeight = activity.getWindowManager().getDefaultDisplay().getHeight();
    }
}

From source file:MainActivity.java

private void zoomFromThumbnail(final ImageView imageViewThumb) {
    if (mCurrentAnimator != null) {
        mCurrentAnimator.cancel();/* w w w  .ja  va 2s.co m*/
    }

    final Rect startBounds = new Rect();
    final Rect finalBounds = new Rect();
    final Point globalOffset = new Point();

    imageViewThumb.getGlobalVisibleRect(startBounds);
    findViewById(R.id.frameLayout).getGlobalVisibleRect(finalBounds, globalOffset);
    mImageViewExpanded
            .setImageBitmap(loadSampledResource(R.drawable.image, finalBounds.height(), finalBounds.width()));

    startBounds.offset(-globalOffset.x, -globalOffset.y);
    finalBounds.offset(-globalOffset.x, -globalOffset.y);

    float startScale;
    if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width()
            / startBounds.height()) {
        startScale = (float) startBounds.height() / finalBounds.height();
        float startWidth = startScale * finalBounds.width();
        float deltaWidth = (startWidth - startBounds.width()) / 2;
        startBounds.left -= deltaWidth;
        startBounds.right += deltaWidth;
    } else {
        startScale = (float) startBounds.width() / finalBounds.width();
        float startHeight = startScale * finalBounds.height();
        float deltaHeight = (startHeight - startBounds.height()) / 2;
        startBounds.top -= deltaHeight;
        startBounds.bottom += deltaHeight;
    }

    imageViewThumb.setVisibility(View.GONE);
    mImageViewExpanded.setVisibility(View.VISIBLE);
    mImageViewExpanded.setPivotX(0f);
    mImageViewExpanded.setPivotY(0f);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(ObjectAnimator.ofFloat(mImageViewExpanded, View.X, startBounds.left, finalBounds.left))
            .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.Y, startBounds.top, finalBounds.top))
            .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.SCALE_X, startScale, 1f))
            .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.SCALE_Y, startScale, 1f));
    animatorSet.setDuration(1000);
    animatorSet.setInterpolator(new AccelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mCurrentAnimator = null;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mCurrentAnimator = null;
        }
    });
    animatorSet.start();
    mCurrentAnimator = animatorSet;
}