Commit 7c47c22e authored by Administrator's avatar Administrator

[fix] 滑动边界问题

parent bf41ac2d
......@@ -159,15 +159,35 @@ public class SwipeUtils {
GestureBean bean = (GestureBean) msg.obj;
long count = bean.count;
if (count >= bean.totalCount) {
Log.i(SuperAppium.TAG, "dispatch MotionEvent.ACTION_UP...");
theView.dispatchInputEvent(genFingerEvent(MotionEvent.ACTION_UP, bean.endX, bean.endY));
isScrolling = false;
} else {
Log.i(SuperAppium.TAG, "dispatch MotionEvent.ACTION_MOVE. now count: " + count + " totalCount: "
+ bean.totalCount + " x: "
+ (bean.startX + bean.ratioX * count)
+ " y: " + (bean.startY + bean.ratioY * count)
);
float x = bean.startX + bean.ratioX * count;
float y = bean.startY + bean.ratioY * count;
boolean upEarly = false;
if (x < 5) {
x = 5;
upEarly = true;
}
if (y < 5) {
y = 5;
upEarly = true;
}
if (x > theView.rootViewImage().getOriginView().getWidth() - 5) {
x = theView.rootViewImage().getOriginView().getWidth() - 5;
upEarly = true;
}
if (y > theView.rootViewImage().getOriginView().getHeight() - 5) {
y = theView.rootViewImage().getOriginView().getHeight() - 5;
upEarly = true;
}
if (upEarly) {
theView.dispatchInputEvent(genFingerEvent(MotionEvent.ACTION_UP, x, y));
isScrolling = false;
return;
}
theView.dispatchPointerEvent(genFingerEvent(MotionEvent.ACTION_MOVE, bean.startX + bean.ratioX * count, bean.startY + bean.ratioY * count));
bean.count++;
Message message = new Message();
......
......@@ -370,12 +370,18 @@ public class ViewImage {
int viewHeight = originView.getHeight();
int fromX = (int) (locs[0] + viewWidth * (ThreadLocalRandom.current().nextDouble(0.4) - 0.2));
if (fromX < 2) {
fromX = 2;
}
int toX = (int) (fromX + viewWidth * (ThreadLocalRandom.current().nextDouble(0.1)));
int fromY = (int) (locs[1] + viewHeight * ThreadLocalRandom.current().nextDouble(0.1));
if (fromY < 2) {
fromY = 2;
}
int toY = fromY + height;
SwipeUtils.simulateScroll(this, fromX, fromY, toX, toY);
SwipeUtils.simulateScroll(this, fromX, fromY, toX, toY, 400, 50);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment