You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/04/01 05:44:07 UTC

incubator-weex git commit: * [android] avoid remove-readd view when fixed component view already moved

Repository: incubator-weex
Updated Branches:
  refs/heads/0.12-dev 355512595 -> 0cceaae4b


* [android] avoid remove-readd view when fixed component view already moved

This bug is found by put a input with fixed-position, rendercontainer will trigger setSize when soft keyborad popup, make input lose focus and keyborad hide, over and over again.


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/0cceaae4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/0cceaae4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/0cceaae4

Branch: refs/heads/0.12-dev
Commit: 0cceaae4b47c082b8d93b2e18fb4e4649cb04fe5
Parents: 3555125
Author: sospartan <so...@apache.org>
Authored: Sat Apr 1 13:43:39 2017 +0800
Committer: sospartan <so...@apache.org>
Committed: Sat Apr 1 13:43:39 2017 +0800

----------------------------------------------------------------------
 .../src/main/java/com/taobao/weex/WXSDKInstance.java    | 12 ++++++++++--
 .../java/com/taobao/weex/ui/component/WXComponent.java  |  7 +------
 2 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0cceaae4/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
index 4139b93..da78ce4 100755
--- a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
+++ b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
@@ -1335,9 +1335,17 @@ public class WXSDKInstance implements IWXActivityStateListener,DomContext, View.
     }
   }
 
-  public void addFixedView(View fixedChild){
+  /**
+   * Move fixed view to container ,except it's already moved.
+   * @param fixedChild
+   */
+  public void moveFixedView(View fixedChild){
     if(mRenderContainer != null) {
-      mRenderContainer.addView(fixedChild);
+      if (fixedChild.getParent() != mRenderContainer) {
+        ViewGroup viewGroup = (ViewGroup) fixedChild.getParent();
+        viewGroup.removeView(fixedChild);
+        mRenderContainer.addView(fixedChild);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0cceaae4/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 8c1a622..44e6c23 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
@@ -161,7 +161,6 @@ import com.taobao.weex.common.IWXObject;
 import com.taobao.weex.common.WXRuntimeException;
 import com.taobao.weex.dom.ImmutableDomObject;
 import com.taobao.weex.dom.WXDomHandler;
-import com.taobao.weex.dom.WXDomManager;
 import com.taobao.weex.dom.WXDomObject;
 import com.taobao.weex.dom.WXDomTask;
 import com.taobao.weex.dom.WXStyle;
@@ -567,17 +566,13 @@ public abstract class  WXComponent<T extends View> implements IWXObject, IWXActi
   }
 
   private void setFixedHostLayoutParams(T host, int width, int height, int left, int right, int top, int bottom){
-    if (host.getParent() instanceof ViewGroup) {
-      ViewGroup viewGroup = (ViewGroup) host.getParent();
-      viewGroup.removeView(host);
-    }
     FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
 
     params.width = width;
     params.height = height;
     params.setMargins(left, top, right, bottom);
     host.setLayoutParams(params);
-    mInstance.addFixedView(host);
+    mInstance.moveFixedView(host);
 
     if (WXEnvironment.isApkDebugable()) {
       WXLogUtils.d("Weex_Fixed_Style", "WXComponent:setLayout :" + left + " " + top + " " + width + " " + height);