This commit is contained in:
hyb1996
2018-04-03 16:09:26 +08:00
parent ebf086af90
commit aeae51bb74
9 changed files with 44 additions and 34 deletions

View File

@@ -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) {
});
}

View File

@@ -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();
}

View File

@@ -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();
}