未验证 提交 f13031b0 编写于 作者: A Amir Hardon 提交者: GitHub

Dispatch platform view touch events to the presentation (#17792)

上级 204adaf2
...@@ -216,7 +216,6 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega ...@@ -216,7 +216,6 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
throw new IllegalStateException( throw new IllegalStateException(
"Sending touch to an unknown view with id: " + touch.viewId); "Sending touch to an unknown view with id: " + touch.viewId);
} }
View view = vdControllers.get(touch.viewId).getView();
MotionEvent event = MotionEvent event =
MotionEvent.obtain( MotionEvent.obtain(
...@@ -235,7 +234,7 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega ...@@ -235,7 +234,7 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
touch.source, touch.source,
touch.flags); touch.flags);
view.dispatchTouchEvent(event); vdControllers.get(touch.viewId).dispatchTouchEvent(event);
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
......
...@@ -11,6 +11,7 @@ import android.content.Context; ...@@ -11,6 +11,7 @@ import android.content.Context;
import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay; import android.hardware.display.VirtualDisplay;
import android.os.Build; import android.os.Build;
import android.view.MotionEvent;
import android.view.Surface; import android.view.Surface;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
...@@ -201,6 +202,12 @@ class VirtualDisplayController { ...@@ -201,6 +202,12 @@ class VirtualDisplayController {
return platformView.getView(); return platformView.getView();
} }
/** Dispatches a motion event to the presentation for this controller. */
public void dispatchTouchEvent(MotionEvent event) {
if (presentation == null) return;
presentation.dispatchTouchEvent(event);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
static class OneTimeOnDrawListener implements ViewTreeObserver.OnDrawListener { static class OneTimeOnDrawListener implements ViewTreeObserver.OnDrawListener {
static void schedule(View view, Runnable runnable) { static void schedule(View view, Runnable runnable) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册