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/08/01 03:02:45 UTC

[incubator-weex] branch master updated: [Android] Avoid duplicated call of setViewPort (#2764)

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 b2a455a  [Android] Avoid duplicated call of setViewPort (#2764)
b2a455a is described below

commit b2a455a4369f96107f9188a2bf255b7fe8572bb5
Author: katherine95s <51...@users.noreply.github.com>
AuthorDate: Thu Aug 1 11:02:40 2019 +0800

    [Android] Avoid duplicated call of setViewPort (#2764)
---
 android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java      | 8 +++++++-
 .../sdk/src/main/java/com/taobao/weex/ui/module/WXMetaModule.java | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

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 c982e80..d07eebd 100644
--- a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
+++ b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
@@ -452,9 +452,15 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan
   }
 
   public void setInstanceViewPortWidth(int instanceViewPortWidth) {
+    setInstanceViewPortWidth(instanceViewPortWidth,false);
+
+  }
+  public void setInstanceViewPortWidth(int instanceViewPortWidth,boolean fromMetaModule){
     this.mInstanceViewPortWidth = instanceViewPortWidth;
     this.mAutoAdjustDeviceWidth = false;
-    WXBridgeManager.getInstance().setViewPortWidth(getInstanceId(),mInstanceViewPortWidth);
+    if(!fromMetaModule){
+      WXBridgeManager.getInstance().setViewPortWidth(getInstanceId(), mInstanceViewPortWidth);
+    }
   }
 
   public void setAutoAdjustDeviceWidth(boolean autoAdjustViewPort){
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/module/WXMetaModule.java b/android/sdk/src/main/java/com/taobao/weex/ui/module/WXMetaModule.java
index c85fb5e..04bb8e4 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/module/WXMetaModule.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/module/WXMetaModule.java
@@ -60,12 +60,12 @@ public class WXMetaModule extends WXModule {
                 // todo maybe getString(WIDTH) is "device-height"
                 if (DEVICE_WIDTH.endsWith(jsObj.getString(WIDTH))) {
                     int width = (int)(WXViewUtils.getScreenWidth(cxt)/WXViewUtils.getScreenDensity(cxt));
-                    mWXSDKInstance.setInstanceViewPortWidth(width);
+                    mWXSDKInstance.setInstanceViewPortWidth(width,true);
                     WXLogUtils.d("[WXMetaModule] setViewport success[device-width]=" + width);
                 } else {
                     int width = jsObj.getInteger(WIDTH);
                     if (width > 0) {
-                        mWXSDKInstance.setInstanceViewPortWidth(width);
+                        mWXSDKInstance.setInstanceViewPortWidth(width,true);
                     }
                     WXLogUtils.d("[WXMetaModule] setViewport success[width]=" + width);
                 }