[Android] Util.convertPxToDp simplification

Jean-Baptiste Kempf git at videolan.org
Fri Jul 11 23:59:55 CEST 2014


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Jul 11 23:59:07 2014 +0200| [34ea90aa6ae66676434b275275512514107988ca] | committer: Jean-Baptiste Kempf

Util.convertPxToDp simplification

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=34ea90aa6ae66676434b275275512514107988ca
---

 vlc-android/src/org/videolan/vlc/util/Util.java |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index 8a67ff9..5d4b4d9 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -31,8 +31,6 @@ import android.content.Context;
 import android.content.res.TypedArray;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
-import android.view.Display;
-import android.view.WindowManager;
 import android.widget.Toast;
 
 public class Util {
@@ -42,11 +40,7 @@ public class Util {
     }
 
     public static int convertPxToDp(int px) {
-        WindowManager wm = (WindowManager)VLCApplication.getAppContext().
-                getSystemService(Context.WINDOW_SERVICE);
-        Display display = wm.getDefaultDisplay();
-        DisplayMetrics metrics = new DisplayMetrics();
-        display.getMetrics(metrics);
+        DisplayMetrics metrics = VLCApplication.getAppResources().getDisplayMetrics();
         float logicalDensity = metrics.density;
         int dp = Math.round(px / logicalDensity);
         return dp;



More information about the Android mailing list