fix: #268
This commit is contained in:
@@ -84,7 +84,6 @@ public abstract class AutoJs {
|
||||
protected void init() {
|
||||
addAccessibilityServiceDelegates();
|
||||
registerActivityLifecycleCallbacks();
|
||||
InputEventObserver.initGlobal(mContext);
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_13, mContext, new BaseLoaderCallback(mContext) {
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,11 +75,16 @@ public class InputEventObserver {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static InputEventObserver getGlobal() {
|
||||
public static InputEventObserver getGlobal(Context context) {
|
||||
if (sGlobal == null) {
|
||||
initGlobal(context);
|
||||
}
|
||||
return sGlobal;
|
||||
}
|
||||
|
||||
public static void initGlobal(Context context) {
|
||||
private static void initGlobal(Context context) {
|
||||
if (sGlobal != null)
|
||||
return;
|
||||
sGlobal = new InputEventObserver(context);
|
||||
sGlobal.observe();
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class Events extends EventEmitter implements OnKeyListener, TouchObserver
|
||||
return;
|
||||
ensureHandler();
|
||||
mLoopers.waitWhenIdle(true);
|
||||
mTouchObserver = new TouchObserver(InputEventObserver.getGlobal());
|
||||
mTouchObserver = new TouchObserver(InputEventObserver.getGlobal(mContext));
|
||||
mTouchObserver.setOnTouchEventListener(this);
|
||||
mTouchObserver.observe();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user