fix #282
This commit is contained in:
@@ -18,15 +18,15 @@ public class ScreenMetrics {
|
||||
private static Display display;
|
||||
|
||||
public static void initIfNeeded(Activity activity) {
|
||||
if (!initialized) {
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
|
||||
deviceScreenHeight = metrics.heightPixels;
|
||||
deviceScreenWidth = metrics.widthPixels;
|
||||
deviceScreenDensity = metrics.densityDpi;
|
||||
display = activity.getWindowManager().getDefaultDisplay();
|
||||
initialized = true;
|
||||
}
|
||||
if(initialized)
|
||||
return;
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
|
||||
deviceScreenHeight = metrics.heightPixels;
|
||||
deviceScreenWidth = metrics.widthPixels;
|
||||
deviceScreenDensity = metrics.densityDpi;
|
||||
display = activity.getWindowManager().getDefaultDisplay();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public static int getDeviceScreenHeight() {
|
||||
|
||||
@@ -19,6 +19,7 @@ public class ViewUtil {
|
||||
return (V) view.findViewById(resId);
|
||||
}
|
||||
|
||||
// FIXME: 2018/1/23 not working in some devices (https://github.com/hyb1996/Auto.js/issues/268)
|
||||
public static int getStatusBarHeight(Context context) {
|
||||
int result = 0;
|
||||
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
|
||||
Reference in New Issue
Block a user