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

[Android]avoid to call setViewPort repeatedly #2764

Merged
merged 1 commit into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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