From d4b19eb4ea7c2e3fbf1b5504cb8f88bdd19d46a2 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 10 Jan 2020 15:02:13 +0800 Subject: [PATCH] android:JSLoader move to JSLoaderManager,not hold by DoricRegistry --- .../src/main/java/pub/doric/DoricRegistry.java | 17 ----------------- .../pub/doric/loader/DoricJSLoaderManager.java | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/DoricRegistry.java b/doric-android/doric/src/main/java/pub/doric/DoricRegistry.java index bfe10294..4e97e848 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricRegistry.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricRegistry.java @@ -17,9 +17,6 @@ package pub.doric; import android.text.TextUtils; -import pub.doric.loader.DoricAssetJSLoader; -import pub.doric.loader.DoricHttpJSLoader; -import pub.doric.loader.IDoricJSLoader; import pub.doric.plugin.AnimatePlugin; import pub.doric.plugin.NavBarPlugin; import pub.doric.plugin.NavigatorPlugin; @@ -50,7 +47,6 @@ import pub.doric.utils.DoricMetaInfo; import pub.doric.plugin.DoricJavaPlugin; import pub.doric.plugin.ModalPlugin; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -65,14 +61,8 @@ import java.util.concurrent.ConcurrentHashMap; public class DoricRegistry { private static Map bundles = new ConcurrentHashMap<>(); private static Set doricLibraries = new HashSet<>(); - private static Set jsLoaders = new HashSet<>(); private Map extendedEnvValues = new HashMap<>(); - static { - addJSLoader(new DoricAssetJSLoader()); - addJSLoader(new DoricHttpJSLoader()); - } - private Map> pluginInfoMap = new HashMap<>(); private Map> nodeInfoMap = new HashMap<>(); @@ -148,13 +138,6 @@ public class DoricRegistry { return bundles.get(name); } - public static void addJSLoader(IDoricJSLoader jsLoader) { - jsLoaders.add(jsLoader); - } - - public static Collection getJSLoaders() { - return jsLoaders; - } public void setEnvironmentVariabel(String key, Object val) { extendedEnvValues.put(key, val); diff --git a/doric-android/doric/src/main/java/pub/doric/loader/DoricJSLoaderManager.java b/doric-android/doric/src/main/java/pub/doric/loader/DoricJSLoaderManager.java index f3c01898..9c1522d1 100644 --- a/doric-android/doric/src/main/java/pub/doric/loader/DoricJSLoaderManager.java +++ b/doric-android/doric/src/main/java/pub/doric/loader/DoricJSLoaderManager.java @@ -17,8 +17,9 @@ package pub.doric.loader; import java.util.Collection; +import java.util.HashSet; +import java.util.Set; -import pub.doric.DoricRegistry; import pub.doric.async.AsyncResult; /** @@ -27,19 +28,32 @@ import pub.doric.async.AsyncResult; * @CreateDate: 2019-11-23 */ public class DoricJSLoaderManager { + + private Set jsLoaders = new HashSet<>(); + private DoricJSLoaderManager() { + addJSLoader(new DoricAssetJSLoader()); + addJSLoader(new DoricHttpJSLoader()); } private static class Inner { private static final DoricJSLoaderManager sInstance = new DoricJSLoaderManager(); } + public void addJSLoader(IDoricJSLoader jsLoader) { + jsLoaders.add(jsLoader); + } + + private Collection getJSLoaders() { + return jsLoaders; + } + public static DoricJSLoaderManager getInstance() { return Inner.sInstance; } public AsyncResult loadJSBundle(String scheme) { - Collection jsLoaders = DoricRegistry.getJSLoaders(); + Collection jsLoaders = getJSLoaders(); for (IDoricJSLoader jsLoader : jsLoaders) { if (jsLoader.filter(scheme)) { return jsLoader.request(scheme);