@@ -44,7 +44,9 @@ public class VenvyUIUtil {
4444 private static final String TAG = "VenvyUIUtil" ;
4545 private static Handler sHandler = new Handler (Looper .getMainLooper ());
4646
47- /** 获取状态栏高度
47+ /**
48+ * 获取状态栏高度
49+ *
4850 * @param v
4951 * @return
5052 */
@@ -59,6 +61,7 @@ public static int getStatusBarHeight(View v) {
5961
6062 /**
6163 * dip 转换成 px
64+ *
6265 * @param dip
6366 * @param context
6467 * @return
@@ -342,7 +345,7 @@ public static boolean removeViewFromParent(View view) {
342345 return false ;
343346 }
344347 final ViewParent parent = view .getParent ();
345- if (parent == null ) {
348+ if (parent == null ) {
346349 return false ;
347350 }
348351 if (parent instanceof ViewGroup ) {
@@ -651,8 +654,14 @@ public static int getScreenWidth(@Nullable Context context) {
651654 return display .getWidth ();
652655 }
653656
657+ public static int getScreenPPI (@ Nullable Context context ) {
658+ DisplayMetrics dm = new DisplayMetrics ();
659+ return dm .densityDpi ;
660+ }
661+
654662 /**
655663 * 获取竖屏屏幕宽度
664+ *
656665 * @param context
657666 * @return
658667 */
@@ -669,6 +678,7 @@ public static int getVerticalScreenWidth(@NonNull Context context) {
669678
670679 /**
671680 * 获取横屏屏幕宽度
681+ *
672682 * @param context
673683 * @return
674684 */
@@ -685,40 +695,41 @@ public static int getVerticalScreenHeight(@NonNull Context context) {
685695
686696 /**
687697 * 获取导航栏高度
698+ *
688699 * @param context
689700 * @return
690701 */
691702 public static int getNavigationBarHeight (Context context ) {
692703 int resourceId ;
693704 int rid = context .getResources ().getIdentifier ("config_showNavigationBar" , "bool" , "android" );
694- if (rid != 0 ) {
705+ if (rid != 0 ) {
695706 resourceId = context .getResources ().getIdentifier ("navigation_bar_height" , "dimen" , "android" );
696707 return context .getResources ().getDimensionPixelSize (resourceId );
697- }else
708+ } else
698709 return 0 ;
699710 }
700711
701712 /**
702713 * @param context
703714 * @return 是否存在导航栏
704715 */
705- public static boolean isNavigationBarShow (Context context ){
716+ public static boolean isNavigationBarShow (Context context ) {
706717 if (!(context instanceof Activity )) {
707718 return false ;
708719 }
709720 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN_MR1 ) {
710- Display display = ((Activity )(context )).getWindowManager ().getDefaultDisplay ();
721+ Display display = ((Activity ) (context )).getWindowManager ().getDefaultDisplay ();
711722 Point size = new Point ();
712723 Point realSize = new Point ();
713724 display .getSize (size );
714725 display .getRealSize (realSize );
715- return realSize .x != size .x ;
716- }else {
726+ return realSize .x != size .x ;
727+ } else {
717728 boolean menu = ViewConfiguration .get (context ).hasPermanentMenuKey ();
718729 boolean back = KeyCharacterMap .deviceHasKey (KeyEvent .KEYCODE_BACK );
719- if (menu || back ) {
730+ if (menu || back ) {
720731 return false ;
721- }else {
732+ } else {
722733 return true ;
723734 }
724735 }
@@ -749,6 +760,7 @@ public static boolean isTopActivity(Context context) {
749760
750761 /**
751762 * 获取 dip
763+ *
752764 * @param context context
753765 * @return DensityDpi
754766 */
0 commit comments