Skip to content

Commit

Permalink
Dispatch platform view touch events to the presentation (flutter#17792)
Browse files Browse the repository at this point in the history
  • Loading branch information
amirh authored Apr 18, 2020
1 parent 204adaf commit f13031b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ public void onTouch(@NonNull PlatformViewsChannel.PlatformViewTouch touch) {
throw new IllegalStateException(
"Sending touch to an unknown view with id: " + touch.viewId);
}
View view = vdControllers.get(touch.viewId).getView();

MotionEvent event =
MotionEvent.obtain(
Expand All @@ -235,7 +234,7 @@ public void onTouch(@NonNull PlatformViewsChannel.PlatformViewTouch touch) {
touch.source,
touch.flags);

view.dispatchTouchEvent(event);
vdControllers.get(touch.viewId).dispatchTouchEvent(event);
}

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;
Expand Down Expand Up @@ -201,6 +202,12 @@ public View 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)
static class OneTimeOnDrawListener implements ViewTreeObserver.OnDrawListener {
static void schedule(View view, Runnable runnable) {
Expand Down

0 comments on commit f13031b

Please sign in to comment.