Observable.create(new AsyncOnSubscribe<Object, Object>() {
@Override
protected Object generateState() {
return null;
}
@Override
protected Object next(Object state, long requested, Observer<Observable<?>> observer) {
return null;
}
}).flatMap(new Func1<Object, Observable<?>>() {
@Override
public Observable<?> call(Object o) {
return null;
}
}).subscribe(new Observer() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(Object o) {
}
});
int y1 = 800;
int y2 = 1000;
int x1 = 200;
int x2 = 400;
int x3 = 600;
int x4 = 800;
Path path1 = new Path();
path1.moveTo(x1, y1);
path1.lineTo(x1, y2);
Path path2 = new Path();
path2.moveTo(x1, y2);
path2.lineTo(x2, y2);
Path path3 = new Path();
path3.moveTo(x2, y2);
path3.lineTo(x4, y2);
Path path4 = new Path();
path4.moveTo(x3, y2);
path4.lineTo(x4, y1);
//rxjava 解决回调地狱
service.dispatchGesture(new GestureDescription.Builder()
.addStroke(new GestureDescription.StrokeDescription(path1, 0, 1000))
.build(), new AccessibilityService.GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
super.onCompleted(gestureDescription);
service.dispatchGesture(new GestureDescription.Builder()
.addStroke(new GestureDescription.StrokeDescription(path2, 0, 1000))
.build(), new AccessibilityService.GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
super.onCompleted(gestureDescription);
service.dispatchGesture(new GestureDescription.Builder()
.addStroke(new GestureDescription.StrokeDescription(path3, 0, 1000))
.build(), new AccessibilityService.GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
super.onCompleted(gestureDescription);
service.dispatchGesture(new GestureDescription.Builder()
.addStroke(new GestureDescription.StrokeDescription(path4, 0, 1000))
.build(), null, null);
}
}, null);
}
}, null);
}
}, null);