Search in sources :

Example 1 with VolatileBox

use of com.stardust.concurrent.VolatileBox in project Auto.js by hyb1996.

the class GlobalActionAutomator method gesturesWithoutHandler.

@RequiresApi(api = Build.VERSION_CODES.N)
private boolean gesturesWithoutHandler(GestureDescription description) {
    prepareLooperIfNeeded();
    final VolatileBox<Boolean> result = new VolatileBox<>(false);
    Handler handler = new Handler(Looper.myLooper());
    mService.dispatchGesture(description, new AccessibilityService.GestureResultCallback() {

        @Override
        public void onCompleted(GestureDescription gestureDescription) {
            result.set(true);
            quitLoop();
        }

        @Override
        public void onCancelled(GestureDescription gestureDescription) {
            result.set(false);
            quitLoop();
        }
    }, handler);
    Looper.loop();
    return result.get();
}
Also used : AccessibilityService(android.accessibilityservice.AccessibilityService) VolatileBox(com.stardust.concurrent.VolatileBox) Handler(android.os.Handler) GestureDescription(android.accessibilityservice.GestureDescription) RequiresApi(android.support.annotation.RequiresApi)

Aggregations

AccessibilityService (android.accessibilityservice.AccessibilityService)1 GestureDescription (android.accessibilityservice.GestureDescription)1 Handler (android.os.Handler)1 RequiresApi (android.support.annotation.RequiresApi)1 VolatileBox (com.stardust.concurrent.VolatileBox)1