|
|
|
|
@ -26,31 +26,43 @@ import com.fongmi.android.tv.App; |
|
|
|
|
public class ResUtil { |
|
|
|
|
|
|
|
|
|
public static DisplayMetrics getDisplayMetrics() { |
|
|
|
|
return App.get().getResources().getDisplayMetrics(); |
|
|
|
|
return getDisplayMetrics(App.get()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static WindowManager getWindowManager() { |
|
|
|
|
return (WindowManager) App.get().getSystemService(Context.WINDOW_SERVICE); |
|
|
|
|
public static DisplayMetrics getDisplayMetrics(Context context) { |
|
|
|
|
return context.getResources().getDisplayMetrics(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static WindowManager getWindowManager(Context context) { |
|
|
|
|
return (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getScreenWidth() { |
|
|
|
|
return getScreenWidth(App.get()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getScreenWidth(Context context) { |
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { |
|
|
|
|
return getWindowManager().getCurrentWindowMetrics().getBounds().width(); |
|
|
|
|
return getWindowManager(context).getCurrentWindowMetrics().getBounds().width(); |
|
|
|
|
} else { |
|
|
|
|
return getDisplayMetrics().widthPixels; |
|
|
|
|
return getDisplayMetrics(context).widthPixels; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getScreenHeight() { |
|
|
|
|
return getScreenHeight(App.get()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static int getScreenHeight(Context context) { |
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { |
|
|
|
|
return getWindowManager().getCurrentWindowMetrics().getBounds().height(); |
|
|
|
|
return getWindowManager(context).getCurrentWindowMetrics().getBounds().height(); |
|
|
|
|
} else { |
|
|
|
|
return getDisplayMetrics().heightPixels; |
|
|
|
|
return getDisplayMetrics(context).heightPixels; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean isEdge(MotionEvent e, int edge) { |
|
|
|
|
return e.getRawX() < edge || e.getRawX() > getScreenWidth() - edge || e.getRawY() < edge || e.getRawY() > getScreenHeight() - edge; |
|
|
|
|
public static boolean isEdge(Context context, MotionEvent e, int edge) { |
|
|
|
|
return e.getRawX() < edge || e.getRawX() > getScreenWidth(context) - edge || e.getRawY() < edge || e.getRawY() > getScreenHeight(context) - edge; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean isLand(Context context) { |
|
|
|
|
|