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

Commit

Permalink
[Android]avoid to call setViewPort repeatedly
Browse files Browse the repository at this point in the history
  • Loading branch information
katherine95s committed Jul 31, 2019
1 parent 76bfd6b commit faef513
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 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,14 @@ public void setUseScroller(boolean use) {
}

public void setInstanceViewPortWidth(int instanceViewPortWidth) {
setInstanceViewPortWidth(instanceViewPortWidth,false);
WXBridgeManager.getInstance().setViewPortWidth(getInstanceId(), mInstanceViewPortWidth);

}
public void setInstanceViewPortWidth(int instanceViewPortWidth,boolean fromMetaModule){
this.mInstanceViewPortWidth = instanceViewPortWidth;
this.mAutoAdjustDeviceWidth = false;
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 faef513

Please sign in to comment.