From 0cd8cb173bb776666fac38918dbbfb59eacc1ca1 Mon Sep 17 00:00:00 2001
From: mueller-ma <mueller-ma@users.noreply.github.com>
Date: Thu, 23 May 2019 18:35:40 +0200
Subject: [PATCH] Use Util.convertDpToPixel() in OsmViewHolder (#1364)

Signed-off-by: mueller-ma <mueller-ma@users.noreply.github.com>
---
 .../org/openhab/habdroid/ui/MapViewHelper.java     | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/mobile/src/foss/java/org/openhab/habdroid/ui/MapViewHelper.java b/mobile/src/foss/java/org/openhab/habdroid/ui/MapViewHelper.java
index 69e6a2fa..51a3e910 100644
--- a/mobile/src/foss/java/org/openhab/habdroid/ui/MapViewHelper.java
+++ b/mobile/src/foss/java/org/openhab/habdroid/ui/MapViewHelper.java
@@ -6,7 +6,6 @@ import android.content.res.Resources;
 import android.location.Location;
 import android.os.Handler;
 import android.preference.PreferenceManager;
-import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.ViewGroup;
@@ -192,7 +191,7 @@ public class MapViewHelper {
                     Log.d(TAG, String.format("North %f, south %f, west %f, east %f",
                             north, south, west, east));
                     BoundingBox boundingBox = new BoundingBox(north, east, south, west);
-                    int extraPixel = (int) convertDpToPixel(24f, mapView.getContext());
+                    int extraPixel = (int) Util.convertDpToPixel(24f, mapView.getContext());
                     try {
                         mapView.zoomToBoundingBox(boundingBox, false, extraPixel);
                     } catch (Exception e) {
@@ -219,17 +218,6 @@ public class MapViewHelper {
             }
         }
 
-        /**
-         * This method converts dp unit to equivalent pixels, depending on device density.
-         *
-         * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels
-         * @param context Context to get resources and device specific display metrics
-         * @return A float value to represent px equivalent to dp depending on device density
-         */
-        private static float convertDpToPixel(float dp, Context context){
-            return dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
-        }
-
         private static void moveCamera(MapView mapView, float zoom, GeoPoint geoPoint) {
             IMapController mapController = mapView.getController();
             mapController.setZoom(zoom);
-- 
GitLab