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 2019/01/09 03:05:57 UTC
[incubator-weex] branch master updated: [WEEX-581][android] fix
'onFocus invoked twice (#1460)
This is an automated email from the ASF dual-hosted git repository.
kyork pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new cd8c6c7 [WEEX-581][android] fix 'onFocus invoked twice (#1460)
cd8c6c7 is described below
commit cd8c6c78f17fa527d563628ada3792a7d15fae68
Author: chenzefeng09 <ch...@gmail.com>
AuthorDate: Wed Jan 9 11:05:52 2019 +0800
[WEEX-581][android] fix 'onFocus invoked twice (#1460)
* fix @focus invoked twice
when set @foucus & @blur method to <input> ,@focus will be called twice when <input> is focused
---
.../sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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 93635f6..ca1b6ec 100644
--- 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
@@ -176,6 +176,7 @@ public abstract class WXComponent<T extends View> extends WXBasicComponent imple
public boolean mIsAddElementToTree = false;
//for fix element case
public int interactionAbsoluteX=0,interactionAbsoluteY=0;
+ private boolean mHasAddFocusListener = false;
public WXTracing.TraceInfo mTraceInfo = new WXTracing.TraceInfo();
@@ -347,7 +348,9 @@ public abstract class WXComponent<T extends View> extends WXBasicComponent imple
}
addClickListener(mClickEventListener);
} else if ((type.equals(Constants.Event.FOCUS) || type.equals(Constants.Event.BLUR))) {
- addFocusChangeListener(new OnFocusChangeListener() {
+ if (!mHasAddFocusListener){
+ mHasAddFocusListener = true;
+ addFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(boolean hasFocus) {
Map<String, Object> params = new HashMap<>();
@@ -355,6 +358,7 @@ public abstract class WXComponent<T extends View> extends WXBasicComponent imple
fireEvent(hasFocus ? Constants.Event.FOCUS : Constants.Event.BLUR, params);
}
});
+ }
} else if (needGestureDetector(type)) {
if (null == view) {
// wait next time to add.