尝试使用fun AccessibilityService.tapCenterOfNode(node: AccessibilityNodeInfo,onDone: (Boolean) -> Any){
this.dispatchPath(
drawPath = pathOnPoint(node.centerInScreen()),pathDuration = 10,onDone = {
success -> Log.d("dispatch","success? $success")
}
)
}
fun AccessibilityService.dispatchPath(drawPath: Path,pathDuration: Long,onDone: (Boolean) -> Any) {
val stroke = GestureDescription.StrokeDescription(drawPath,pathDuration)
val gesture = GestureDescription.Builder().addStroke(stroke).build()
this.dispatchGesture(gesture,object : AccessibilityService.GestureResultCallback() {
override fun onCompleted(gestureDescription: GestureDescription) {
super.onCompleted(gestureDescription)
onDone(true)
}
override fun onCancelled(gestureDescription: GestureDescription) {
super.onCancelled(gestureDescription)
onDone(false)
}
},null)
}
fun AccessibilityNodeInfo.centerInScreen(): Pair<Float,Float> =
Pair(this.getBoundsInScreen().exactCenterX(),this.getBoundsInScreen().exactCenterY())
fun AccessibilityNodeInfo.getBoundsInScreen(): Rect {
val rect = Rect()
getBoundsInScreen(rect)
return rect
}
fun pathOnPoint(point: Pair<Float,Float>) = Path().apply {
val (x,y) = point
moveTo(x,y)
lineTo(x,y)
}
单击搜索栏的中心:
consumeRecord.keyBy("gameType")
.timeWindowAll(Time.seconds(5))
.reduce((d1,d2) -> {
d1.setRealPumpAmount(d1.getRealPumpAmount() + d2.getRealPumpAmount());
d1.setPumpAmount(d1.getPumpAmount() + d2.getPumpAmount());
return d1;
})
.addSink(new SinkFunction<ReportPump>() {
@Override
public void invoke(ReportPump value,Context context) throws Exception {
// save to mysql
}
});
本文链接:https://www.f2er.com/2503325.html