/*
 * *
 *  * LayoutUtil.java
 *  * as part of mkcommons-android
 *  *
 *  * Created by michaelkuck, last updated on 7/25/14 1:00 PM
 *  * Unless otherwise stated in a separate LICENSE file for this project
 *  * or agreed via contract, all rights reserved by the author.
 *
 */

package com.michael_kuck.android.mkcommons;

import android.content.Context;
import android.graphics.Point;
import android.util.TypedValue;

/**
 * Created by michaelkuck on 7/25/14.
 */
public class LayoutUtil {

    public static Point dpToP(final Context context, final Point point) {
        int x = (int) TypedValue
                .applyDimension(TypedValue.COMPLEX_UNIT_DIP, point.x, context.getResources().getDisplayMetrics());
        int y = (int) TypedValue
                .applyDimension(TypedValue.COMPLEX_UNIT_DIP, point.y, context.getResources().getDisplayMetrics());
        return new Point(x, y);
    }

    public static int dpToP(final Context context, final int pixel) {
        return (int) TypedValue
                .applyDimension(TypedValue.COMPLEX_UNIT_DIP, pixel, context.getResources().getDisplayMetrics());
    }

}

@@ -369,22 +369,92 @@
 oid.
-graphics.Point
+content.res.Resources;%0Aimport android.graphics.Point;%0Aimport android.graphics.PointF
 ;%0Aim
@@ -579,63 +579,125 @@
 tic 
-Point dpToP(final Context context, final Point point) %7B
+float pixelFromDp(final float dpPixel) %7B%0A        final Resources resources = Android.getApplication().getResources();
 %0A   
@@ -705,49 +705,38 @@
     
+f
 in
-t x = (int) TypedValue%0A                
+al float pixel = TypedValue
 .app
@@ -780,37 +780,26 @@
 IP, 
-point.x, context.getR
+dpPixel, r
 esources
 ().g
@@ -786,34 +786,32 @@
 Pixel, resources
-()
 .getDisplayMetri
@@ -829,177 +829,131 @@
     
-int y = (int) TypedValue%0A                .applyDimension(TypedValue.COMPLEX_UNIT_DIP, point.y, context.getResources().getDisplayMetrics());%0A        return new Point(x, y
+return pixel;%0A    %7D%0A%0A    public static int pixelFromDp(final int dpPixel) %7B%0A        return (int) pixelFromDp((float)dpPixel
 );%0A 
@@ -980,203 +980,357 @@
 tic 
+Po
 int
- dpToP(final Context context,
+F pixelsFromDpPoint(final PointF dpPixels) %7B%0A       
  final 
+Po
 int
+F
  pixel
-) %7B%0A        return (int) TypedValue%0A                .applyDimension(TypedValue.COMPLEX_UNIT_DIP, pixel, context.getResources().getDisplayMetrics())
+s = new PointF(pixelFromDp(dpPixels.x), pixelFromDp(dpPixels.y));%0A        return pixels;%0A    %7D%0A%0A    public static Point pixelsFromDpPoint(final Point dpPixels) %7B%0A        final Point pixels = new Point(pixelFromDp(dpPixels.x), pixelFromDp(dpPixels.y));%0A        return pixels
 ;%0A  

Add methods for converting resolution independent pixels (dp) to real pixels and the other way round.