android: fix npe when create plugin error

This commit is contained in:
pengfei.zhou 2021-04-29 11:13:51 +08:00 committed by osborn
parent bdab13209c
commit 2e3f8f3cea

View File

@ -53,7 +53,7 @@ public class DoricContext {
private final String mContextId;
private final Map<String, DoricJavaPlugin> mPluginMap = new HashMap<>();
private final Context mContext;
private RootNode mRootNode = new RootNode(this);
private final RootNode mRootNode = new RootNode(this);
private final String source;
private String script;
private String extra;
@ -198,8 +198,10 @@ public class DoricContext {
DoricJavaPlugin plugin = mPluginMap.get(doricMetaInfo.getName());
if (plugin == null) {
plugin = doricMetaInfo.createInstance(this);
if (plugin != null) {
mPluginMap.put(doricMetaInfo.getName(), plugin);
}
}
return plugin;
}
@ -281,7 +283,9 @@ public class DoricContext {
*/
public void onActivityResult(int requestCode, int resultCode, Intent data) {
for (DoricJavaPlugin javaPlugin : mPluginMap.values()) {
if (javaPlugin != null) {
javaPlugin.onActivityResult(requestCode, resultCode, data);
}
}
}
}