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

This commit is contained in:
Amir Hardon 2020-04-17 17:19:10 -07:00 committed by GitHub
parent 204adaf268
commit f13031b026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -216,7 +216,6 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
throw new IllegalStateException(
"Sending touch to an unknown view with id: " + touch.viewId);
}
View view = vdControllers.get(touch.viewId).getView();
MotionEvent event =
MotionEvent.obtain(
@ -235,7 +234,7 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
touch.source,
touch.flags);
view.dispatchTouchEvent(event);
vdControllers.get(touch.viewId).dispatchTouchEvent(event);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)

View File

@ -11,6 +11,7 @@ import android.content.Context;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.os.Build;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewTreeObserver;
@ -201,6 +202,12 @@ class VirtualDisplayController {
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)
static class OneTimeOnDrawListener implements ViewTreeObserver.OnDrawListener {
static void schedule(View view, Runnable runnable) {