mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-24 21:33:16 +08:00
修复device.width为0的问题
This commit is contained in:
parent
5fcfa88ae0
commit
2916eca378
@ -159,6 +159,7 @@ public abstract class AutoJs {
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
ScreenMetrics.initIfNeeded(activity);
|
||||
mAppUtils.setCurrentActivity(activity);
|
||||
}
|
||||
});
|
||||
|
||||
@ -38,9 +38,9 @@ import ezy.assist.compat.SettingsCompat;
|
||||
|
||||
public class Device {
|
||||
|
||||
public static final int width = ScreenMetrics.getDeviceScreenWidth();
|
||||
public static int width = ScreenMetrics.getDeviceScreenWidth();
|
||||
|
||||
public static final int height = ScreenMetrics.getDeviceScreenHeight();
|
||||
public static int height = ScreenMetrics.getDeviceScreenHeight();
|
||||
|
||||
public static final String buildId = Build.ID;
|
||||
|
||||
@ -93,6 +93,8 @@ public class Device {
|
||||
|
||||
public Device(Context context) {
|
||||
mContext = context;
|
||||
width = ScreenMetrics.getDeviceScreenWidth();
|
||||
height = ScreenMetrics.getDeviceScreenHeight();
|
||||
}
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
|
||||
@ -2,12 +2,8 @@ package com.stardust.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
|
||||
import static java.lang.System.out;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/4/26.
|
||||
@ -22,7 +18,7 @@ public class ScreenMetrics {
|
||||
private static Display display;
|
||||
|
||||
public static void initIfNeeded(Activity activity) {
|
||||
if (initialized)
|
||||
if (initialized && deviceScreenHeight != 0)
|
||||
return;
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user