Commit c5b9fc63 authored by Administrator's avatar Administrator

滑动丢失ACTION_UP Event问题

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