package com.hitherejoe.androidboilerplate.util;

import android.content.Context;
import android.util.DisplayMetrics;

public class ViewUtils {

    public static float convertPixelsToDp(float px, Context context){
        DisplayMetrics metrics = context.getResources().getDisplayMetrics();
        return px / (metrics.densityDpi / 160f);
    }

}

@@ -42,16 +42,45 @@
 .util;%0A%0A
+import android.app.Activity;%0A
 import a
@@ -122,179 +122,364 @@
 oid.
-util.DisplayMetrics;%0A%0Apublic class ViewUtils %7B%0A%0A    public static float convertPixelsToDp(float px, Context context)%7B%0A        DisplayMetrics metrics = context.getResources
+content.res.Resources;%0Aimport android.view.inputmethod.InputMethodManager;%0A%0Apublic class ViewUtils %7B%0A%0A    public static float pxToDp(float px) %7B%0A        float densityDpi = Resources.getSystem().getDisplayMetrics().densityDpi;%0A        return px / (densityDpi / 160f);%0A    %7D%0A%0A    public static int dpToPx(int dp) %7B%0A        float density = Resources.getSystem
 ().g
@@ -496,16 +496,24 @@
 etrics()
+.density
 ;%0A      
@@ -525,39 +525,300 @@
 urn 
-px / (metrics.densityDpi / 160f
+Math.round(dp * density);%0A    %7D%0A%0A    public static void hideKeyboard(Activity activity) %7B%0A        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);%0A        imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0
 );%0A 

Add methods to ViewUtils