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

[Android]fix setViewPort invalid #2738

Merged
merged 1 commit into from
Jul 23, 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 @@ -454,6 +454,7 @@ public void setUseScroller(boolean use) {
public void setInstanceViewPortWidth(int instanceViewPortWidth) {
this.mInstanceViewPortWidth = instanceViewPortWidth;
this.mAutoAdjustDeviceWidth = false;
WXBridgeManager.getInstance().setViewPortWidth(getInstanceId(),mInstanceViewPortWidth);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to call c++ code if this setInstanceViewPortWidth is invoked by WXMetaModule.setViewport

}

public void setAutoAdjustDeviceWidth(boolean autoAdjustViewPort){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public class WXBridge implements IWXBridge {
* */
public native void nativeUpdateGlobalConfig(String config);

private native void nativeSetViewPortWidth(String instanceId, float viewPortWidth);

public static final boolean MULTIPROCESS = true;


Expand Down Expand Up @@ -765,6 +767,10 @@ public void setInstanceRenderType(String instanceId, String renderType){
nativeSetInstanceRenderType(instanceId, renderType);
}

@Override
public void setViewPortWidth(String instanceId,float viewPortWidth){
nativeSetViewPortWidth(instanceId,viewPortWidth);
}

@Override
public void removeInstanceRenderType(String instanceId){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3338,6 +3338,11 @@ public void markDirty(String instanceId, String ref, boolean dirty) {
mWXBridge.markDirty(instanceId, ref, dirty);
}
}
public void setViewPortWidth(String instanceId,float viewPortWidth){
if (isSkipFrameworkInit(instanceId) || isJSFrameworkInit()) {
mWXBridge.setViewPortWidth(instanceId,viewPortWidth);
}
}

public int callHasTransitionPros(String instanceId, String ref, HashMap<String, String> styles) {
WXComponent component = WXSDKManager.getInstance().getWXRenderManager().getWXComponent(instanceId, ref);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,6 @@ int callUpdateAttrs(String instanceId, String ref,

void setPageArgument(String instanceId, String key, String value);

void setViewPortWidth(String instanceId,float viewPortWidth);

}
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ static void SetInstanceRenderType(JNIEnv* env, jobject jcaller,
static void RemoveInstanceRenderType(JNIEnv* env, jobject jcaller,
jstring instanceId);

static void SetViewPortWidth(JNIEnv* env, jobject jcaller,
jstring instanceId,jfloat viewPortWidth);

static void SetPageArgument(JNIEnv* env, jobject jcaller,
jstring instanceId,
jstring key,
Expand Down Expand Up @@ -1204,6 +1207,12 @@ static const JNINativeMethod kMethodsWXBridge[] = {
"Ljava/lang/String;"
")"
"V", reinterpret_cast<void*>(RemoveInstanceRenderType) },
{ "nativeSetViewPortWidth",
"("
"Ljava/lang/String;"
"F"
")"
"V", reinterpret_cast<void*>(SetViewPortWidth)},
};

static bool RegisterNativesImpl(JNIEnv* env) {
Expand Down