You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/01/09 03:05:54 UTC

[GitHub] YorkShen closed pull request #1460: [WEEX-581][android] fix 'onFocus invoked twice

YorkShen closed pull request #1460: [WEEX-581][android] fix 'onFocus invoked twice
URL: https://github.com/apache/incubator-weex/pull/1460
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 1e1353ed2c..10913a56f6 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
@@ -175,6 +175,7 @@
   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();
 
@@ -375,7 +376,9 @@ public void addEvent(final String type) {
       }
       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<>();
@@ -383,6 +386,7 @@ public void onFocusChange(boolean hasFocus) {
           fireEvent(hasFocus ? Constants.Event.FOCUS : Constants.Event.BLUR, params);
         }
       });
+      }
     } else if (needGestureDetector(type)) {
       if (null == view) {
         // wait next time to add.


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services