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

Commit

Permalink
* [android] Fix crash due to instanceId is null
Browse files Browse the repository at this point in the history
  • Loading branch information
miomin authored and YorkShen committed Jul 31, 2018
1 parent 66571ad commit 2e9a078
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public ScrollView getScrollView() {

public void setRootScrollView(ScrollView scrollView) {
mScrollView = scrollView;
if (mWXScrollViewListener != null) {
if (mWXScrollViewListener != null && mScrollView instanceof WXScrollView) {
((WXScrollView) mScrollView).addScrollViewListener(mWXScrollViewListener);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public enum WXErrorCode {
WX_RENDER_ERR_NULL_KEY("-9603", "WX_RENDER_ERR_NULL_KEY", ErrorType.NATIVE_ERROR, ErrorGroup.NATIVE),
WX_RENDER_ERR_CONTAINER_TYPE("-9611", "WX_RENDER_ERR_CONTAINER_TYPE", ErrorType.JS_ERROR,ErrorGroup.JS),
WX_RENDER_ERR_TRANSITION("-9616", "WX_RENDER_ERR_TRANSITION", ErrorType.JS_ERROR, ErrorGroup.JS),

WX_RENDER_ERR_INSTANCE_ID_NULL("-9618", "WX_RENDER_ERR_INSTANCE_ID_NULL", ErrorType.NATIVE_ERROR, ErrorGroup.NATIVE),


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
import android.text.TextUtils;

import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.common.WXErrorCode;
import com.taobao.weex.common.WXRuntimeException;
import com.taobao.weex.common.WXThread;
import com.taobao.weex.dom.RenderContext;
import com.taobao.weex.ui.action.BasicGraphicAction;
import com.taobao.weex.ui.component.WXComponent;
import com.taobao.weex.utils.WXExceptionUtils;
import com.taobao.weex.utils.WXUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -122,7 +124,15 @@ public void postGraphicAction(final String instanceId, final BasicGraphicAction
}

public void registerInstance(WXSDKInstance instance) {
mRenderContext.put(instance.getInstanceId(), new RenderContextImpl(instance));
if (instance.getInstanceId() == null) {
WXExceptionUtils.commitCriticalExceptionRT(null,
WXErrorCode.WX_RENDER_ERR_INSTANCE_ID_NULL,
"registerInstance",
WXErrorCode.WX_RENDER_ERR_INSTANCE_ID_NULL.getErrorMsg() + "instanceId is null",
null);
} else {
mRenderContext.put(instance.getInstanceId(), new RenderContextImpl(instance));
}
}

public List<WXSDKInstance> getAllInstances() {
Expand Down

0 comments on commit 2e9a078

Please sign in to comment.