Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[Android] Avoid duplicated call of setViewPort (#2764)
Browse files Browse the repository at this point in the history
  • Loading branch information
katherine95s authored and YorkShen committed Aug 1, 2019
1 parent b943ea4 commit b2a455a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,15 @@ public void setUseScroller(boolean use) {
}

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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public void setViewport(String param) {
// 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);
}
Expand Down

0 comments on commit b2a455a

Please sign in to comment.