Skip to content

Commit

Permalink
feat(android): add disallowInterceptTouchEvent for hippy view group
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 authored and hippy-actions[bot] committed Jan 22, 2024
1 parent c035630 commit 7bf7ac7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public class NodeProps {
public static final String ON_TOUCH_CANCEL = "touchcancel";
public static final String ON_INTERCEPT_TOUCH_EVENT = "onInterceptTouchEvent";
public static final String ON_INTERCEPT_PULL_UP_EVENT = "onInterceptPullUpEvent";
public static final String DISALLOW_INTERCEPT_TOUCH_EVENT = "disallowInterceptTouchEvent";
public static final String ON_ATTACHED_TO_WINDOW = "attachedtowindow";
public static final String ON_DETACHED_FROM_WINDOW = "detachedfromwindow";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.tencent.mtt.hippy.views.view;

import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.tencent.mtt.hippy.dom.node.NodeProps;
Expand All @@ -36,6 +37,7 @@ public class HippyViewGroup extends FlatViewGroup implements HippyViewBase {
float mDownX = 0;
float mDownY = 0;
boolean isHandlePullUp = false;
private boolean mDisallowInterceptTouchEvent = false;
private ViewConfiguration mViewConfiguration;
@Nullable
protected NativeGestureDispatcher mGestureDispatcher;
Expand Down Expand Up @@ -73,6 +75,10 @@ public void setOverflow(String overflow) {
setOverflow(overflow, this);
}

public void setDisallowInterceptTouchEvent(boolean disallow) {
mDisallowInterceptTouchEvent = disallow;
}

public static void setOverflow(@NonNull String overflow, @NonNull ViewGroup viewGroup) {
switch (overflow) {
case NodeProps.VISIBLE:
Expand All @@ -91,6 +97,12 @@ public static void setOverflow(@NonNull String overflow, @NonNull ViewGroup view
public boolean onInterceptTouchEvent(MotionEvent ev) {
int action = ev.getAction() & MotionEvent.ACTION_MASK;
if (action == MotionEvent.ACTION_DOWN) {
if (mDisallowInterceptTouchEvent) {
ViewParent parent = getParent();
if (parent != null) {
parent.requestDisallowInterceptTouchEvent(true);
}
}
mDownX = ev.getX();
mDownY = ev.getY();
isHandlePullUp = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public void setOverflow(HippyViewGroup viewGroup, String overflow) {
viewGroup.setOverflow(overflow);
}

@HippyControllerProps(name = NodeProps.DISALLOW_INTERCEPT_TOUCH_EVENT, defaultType = HippyControllerProps.BOOLEAN)
public void setDisallowInterceptTouchEvent(HippyViewGroup view, boolean disallow) {
view.setDisallowInterceptTouchEvent(disallow);
}

@SuppressWarnings("deprecation")
@Override
public void dispatchFunction(@NonNull HippyViewGroup viewGroup, @NonNull String functionName,
Expand Down

0 comments on commit 7bf7ac7

Please sign in to comment.