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 06:03:54 UTC
[49/50] [abbrv] incubator-weex git commit: * [android] avoid
remove-readd view when fixed component view already moved
* [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/9495bf2e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/9495bf2e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/9495bf2e
Branch: refs/heads/dev
Commit: 9495bf2e97830fca06b34a40236cfa2db1cb758b
Parents: fef125b
Author: sospartan <so...@apache.org>
Authored: Sat Apr 1 13:43:39 2017 +0800
Committer: sospartan <so...@apache.org>
Committed: Sat Apr 1 13:44:56 2017 +0800
----------------------------------------------------------------------
.../src/main/java/com/taobao/weex/WXSDKInstance.java | 12 ++++++++++--
.../java/com/taobao/weex/ui/component/WXComponent.java | 6 +-----
2 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9495bf2e/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 c70b405..0131363 100755
--- a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
+++ b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
@@ -1292,9 +1292,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/9495bf2e/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 8785064..63f5204 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
@@ -563,17 +563,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);