You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2017/04/10 02:21:15 UTC
[1/2] incubator-weex git commit: * [android] disable click event when
gesture already consume touch event
Repository: incubator-weex
Updated Branches:
refs/heads/0.12-dev 6e4dcfb96 -> 43eb4dfcd
* [android] disable click event when gesture already consume touch event
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/36a8b880
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/36a8b880
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/36a8b880
Branch: refs/heads/0.12-dev
Commit: 36a8b8805a49bdb4252e10795326d67d73d3daca
Parents: 41c8ef6
Author: sospartan <so...@apache.org>
Authored: Thu Apr 6 15:03:11 2017 +0800
Committer: sospartan <so...@apache.org>
Committed: Thu Apr 6 15:03:11 2017 +0800
----------------------------------------------------------------------
.../com/taobao/weex/ui/component/WXComponent.java | 4 ++++
.../com/taobao/weex/ui/view/gesture/WXGesture.java | 14 ++++++++++++++
2 files changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/36a8b880/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
index 44e6c23..4c0a9a7 100755
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
@@ -422,6 +422,10 @@ public abstract class WXComponent<T extends View> implements IWXObject, IWXActi
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ if(mGesture != null && mGesture.isTouchEventConsumed()){
+ //event is already consumed by gesture
+ return;
+ }
for (OnClickListener listener : mHostClickListeners){
if(listener != null) {
listener.onHostViewClick();
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/36a8b880/android/sdk/src/main/java/com/taobao/weex/ui/view/gesture/WXGesture.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/view/gesture/WXGesture.java b/android/sdk/src/main/java/com/taobao/weex/ui/view/gesture/WXGesture.java
index 95bb112..05b9c9d 100755
--- a/android/sdk/src/main/java/com/taobao/weex/ui/view/gesture/WXGesture.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/view/gesture/WXGesture.java
@@ -256,6 +256,7 @@ public class WXGesture extends GestureDetector.SimpleOnGestureListener implement
private WXGestureType mPendingPan = null;//event type to notify when action_up or action_cancel
private int mParentOrientation =-1;
private boolean mIsPreventMoveEvent = false;
+ private boolean mIsTouchEventConsumed = false; //Reset to false when first touch event, set to true when gesture event fired.
public WXGesture(WXComponent wxComponent, Context context) {
this.component = wxComponent;
@@ -288,6 +289,15 @@ public class WXGesture extends GestureDetector.SimpleOnGestureListener implement
mIsPreventMoveEvent = preventMoveEvent;
}
+ /**
+ *
+ * @return true if current touch event is already consumed by gesture.
+ * Reset to false when next first touch event, set to true when gesture event fired.
+ */
+ public boolean isTouchEventConsumed(){
+ return mIsTouchEventConsumed;
+ }
+
@Override
public boolean onTouch(View v, MotionEvent event) {
try {
@@ -295,6 +305,7 @@ public class WXGesture extends GestureDetector.SimpleOnGestureListener implement
switch (event.getActionMasked()) {
case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_DOWN:
+ mIsTouchEventConsumed = false;
/**
* If component has same scroll orientation with it's parent and it's parent not scrollable
* , we should disallow parent in DOWN.
@@ -309,12 +320,14 @@ public class WXGesture extends GestureDetector.SimpleOnGestureListener implement
break;
case MotionEvent.ACTION_MOVE:
result |= handleMotionEvent(LowLevelGesture.ACTION_MOVE, event);
+ mIsTouchEventConsumed = mIsTouchEventConsumed || result;
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
finishDisallowInterceptTouchEvent(v);
result |= handleMotionEvent(LowLevelGesture.ACTION_UP, event);
result |= handlePanMotionEvent(event);
+ mIsTouchEventConsumed = mIsTouchEventConsumed || result;
break;
case MotionEvent.ACTION_CANCEL:
finishDisallowInterceptTouchEvent(v);
@@ -627,6 +640,7 @@ public class WXGesture extends GestureDetector.SimpleOnGestureListener implement
component.getDomObject().getRef(),
HighLevelGesture.LONG_PRESS.toString(),
list.get(list.size() - 1));
+ mIsTouchEventConsumed = mIsTouchEventConsumed || true;
}
}
[2/2] incubator-weex git commit: Merge branch '0.12-fix-one-event' of
https://github.com/sospartan/incubator-weex into 0.12-dev
Posted by ky...@apache.org.
Merge branch '0.12-fix-one-event' of https://github.com/sospartan/incubator-weex into 0.12-dev
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/43eb4dfc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/43eb4dfc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/43eb4dfc
Branch: refs/heads/0.12-dev
Commit: 43eb4dfcd0f7cc7de0bc891878d30e0c79ee04db
Parents: 6e4dcfb 36a8b88
Author: YorkShen <sh...@gmail.com>
Authored: Mon Apr 10 10:20:38 2017 +0800
Committer: YorkShen <sh...@gmail.com>
Committed: Mon Apr 10 10:20:38 2017 +0800
----------------------------------------------------------------------
.../com/taobao/weex/ui/component/WXComponent.java | 4 ++++
.../com/taobao/weex/ui/view/gesture/WXGesture.java | 14 ++++++++++++++
2 files changed, 18 insertions(+)
----------------------------------------------------------------------