Commit c5b9fc63 authored by Administrator's avatar Administrator

滑动丢失ACTION_UP Event问题

parent c80bdbb2
......@@ -105,15 +105,15 @@ public class SwipeUtils {
isScrolling = true;
Handler handler = new ViewHandler(object);
//重置相对偏移
int[] loca = new int[2];
object.rootViewImage().getOriginView().getLocationOnScreen(loca);
startX -= loca[0];
endX -= loca[0];
startY -= loca[1];
endY -= loca[1];
// //重置相对偏移
// int[] loca = new int[2];
// object.rootViewImage().getOriginView().getLocationOnScreen(loca);
//
// startX -= loca[0];
// endX -= loca[0];
//
// startY -= loca[1];
// endY -= loca[1];
object.dispatchPointerEvent(genFingerEvent(MotionEvent.ACTION_DOWN, startX, startY));
......@@ -123,7 +123,7 @@ public class SwipeUtils {
private static MotionEvent genFingerEvent(int action, float x, float y) {
// Log.i("HD_HOOK", "genFingerEvent action: " + action + " point:(" + x + " , " + y + ")");
Log.i("HD_HOOK", "genFingerEvent action: " + action + " point:(" + x + " , " + y + ")");
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
......@@ -162,8 +162,17 @@ public class SwipeUtils {
GestureBean bean = (GestureBean) msg.obj;
long count = bean.count;
if (count >= bean.totalCount) {
theView.dispatchInputEvent(genFingerEvent(MotionEvent.ACTION_UP, bean.endX, bean.endY));
theView.dispatchPointerEvent(genFingerEvent(MotionEvent.ACTION_MOVE, bean.endX, bean.endY));
new Handler(Looper.myLooper()).post(
new Runnable() {
@Override
public void run() {
theView.dispatchPointerEvent(genFingerEvent(MotionEvent.ACTION_UP, bean.endX, bean.endY));
}
}
);
isScrolling = false;
} else {
float x = bean.startX + bean.ratioX * count;
float y = bean.startY + bean.ratioY * count;
......@@ -186,7 +195,17 @@ public class SwipeUtils {
}
if (upEarly) {
theView.dispatchInputEvent(genFingerEvent(MotionEvent.ACTION_UP, x, y));
theView.dispatchPointerEvent(genFingerEvent(MotionEvent.ACTION_MOVE, x, y));
float finalX = x;
float finalY = y;
new Handler(Looper.myLooper()).post(
new Runnable() {
@Override
public void run() {
theView.dispatchPointerEvent(genFingerEvent(MotionEvent.ACTION_UP, finalX, finalY));
}
}
);
isScrolling = false;
return;
}
......
......@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.util.Log;
import android.view.InputEvent;
import android.view.MotionEvent;
import android.view.View;
......@@ -348,6 +349,7 @@ public class ViewImage {
View rootView = rootViewImage().getOriginView();
final Object mViewRootImpl = RposedHelpers.callMethod(rootView, "getViewRootImpl");
if (mViewRootImpl == null) {
Log.w(SuperAppium.TAG, "can not find RootViewImpl to dispatch event");
return false;
}
RposedHelpers.callMethod(mViewRootImpl, "dispatchInputEvent", inputEvent);
......
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