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

[WEEX][Android] NestInstance Support Downgrade To Full Page Root Instance #1952

Merged
merged 1 commit into from
Jan 8, 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
13 changes: 13 additions & 0 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan

private List<String> mLayerOverFlowListeners;

private WXSDKInstance mParentInstance;

public List<String> getLayerOverFlowListeners() {
return mLayerOverFlowListeners;
}
Expand Down Expand Up @@ -1499,6 +1501,14 @@ public void run() {
mWXPerformance.screenRenderTime = System.currentTimeMillis() - mRenderStartTime;
}

public WXSDKInstance getParentInstance() {
return mParentInstance;
}

public void setParentInstance(WXSDKInstance mParentInstance) {
this.mParentInstance = mParentInstance;
}

private void destroyView(View rootView) {
try {
if (rootView instanceof ViewGroup) {
Expand All @@ -1522,6 +1532,9 @@ private void destroyView(View rootView) {

public synchronized void destroy() {
if(!isDestroy()) {
if(mParentInstance != null){
mParentInstance = null;
}
mApmForInstance.onEnd();
if(mRendered) {
WXSDKManager.getInstance().destroyInstance(mInstanceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package com.taobao.weex.common;

import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.annotation.JSMethod;

/**
Expand All @@ -28,7 +29,13 @@ public class WXInstanceWrap extends WXModule {
@JSMethod
public void error(String type, String code, String info) {
if (mWXSDKInstance != null) {
mWXSDKInstance.onRenderError(type + "|" + code, info);
WXSDKInstance root = mWXSDKInstance;
if(info != null && info.contains("downgrade_to_root")){
while (root.getParentInstance() != null){
root = root.getParentInstance();
}
}
root.onRenderError(type + "|" + code, info);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ private static final int getLevel(WXEmbed embed){

private WXSDKInstance createInstance() {
WXSDKInstance sdkInstance = getInstance().createNestedInstance(this);

sdkInstance.setParentInstance(getInstance());
boolean needsAdd = !getAttrs().containsKey("disableInstanceVisibleListener");
if(needsAdd){ //prevent switch off fire viewappear event twice
getInstance().addOnInstanceVisibleListener(this);
Expand Down