|
|
|
|
@ -1,11 +1,10 @@ |
|
|
|
|
package com.fongmi.android.tv.utils; |
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.content.Context; |
|
|
|
|
import android.content.res.Configuration; |
|
|
|
|
import android.content.res.Resources; |
|
|
|
|
import android.content.res.TypedArray; |
|
|
|
|
import android.graphics.Paint; |
|
|
|
|
import android.graphics.Point; |
|
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
|
import android.util.DisplayMetrics; |
|
|
|
|
import android.util.TypedValue; |
|
|
|
|
@ -29,22 +28,6 @@ public class ResUtil { |
|
|
|
|
return App.get().getResources().getDisplayMetrics(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean hasNavigationBar(Context context) { |
|
|
|
|
Display display = getDisplay(context); |
|
|
|
|
Point size = new Point(); |
|
|
|
|
Point realSize = new Point(); |
|
|
|
|
display.getSize(size); |
|
|
|
|
display.getRealSize(realSize); |
|
|
|
|
return realSize.x != size.x || realSize.y != size.y; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getNavigationBarHeight(Context context) { |
|
|
|
|
if (!hasNavigationBar(context)) return 0; |
|
|
|
|
Resources resources = context.getResources(); |
|
|
|
|
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); |
|
|
|
|
return resources.getDimensionPixelSize(resourceId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getScreenWidth() { |
|
|
|
|
return getDisplayMetrics().widthPixels; |
|
|
|
|
} |
|
|
|
|
@ -53,10 +36,6 @@ public class ResUtil { |
|
|
|
|
return context.getResources().getDisplayMetrics().widthPixels; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getScreenWidthNav() { |
|
|
|
|
return getDisplayMetrics().widthPixels + getNavigationBarHeight(App.get()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getScreenHeight() { |
|
|
|
|
return getDisplayMetrics().heightPixels; |
|
|
|
|
} |
|
|
|
|
@ -65,12 +44,8 @@ public class ResUtil { |
|
|
|
|
return context.getResources().getDisplayMetrics().heightPixels; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getScreenHeightNav() { |
|
|
|
|
return getDisplayMetrics().heightPixels + getNavigationBarHeight(App.get()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean isEdge(MotionEvent e, int edge) { |
|
|
|
|
return e.getRawX() < edge || e.getRawX() > getScreenWidthNav() - edge || e.getRawY() < edge || e.getRawY() > getScreenHeightNav() - edge; |
|
|
|
|
public static boolean isEdge(Activity activity, MotionEvent e, int edge) { |
|
|
|
|
return e.getRawX() < edge || e.getRawX() > getScreenWidth(activity) - edge || e.getRawY() < edge || e.getRawY() > getScreenHeight(activity) - edge; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean isLand(Context context) { |
|
|
|
|
|