From 0a54a5a5e73b3fe1bfc1b7c8ec96042c0de443df Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Thu, 22 Jul 2021 19:01:58 +0800 Subject: [PATCH] feat:add deprecated api --- doric-android/doric/src/main/java/pub/doric/Doric.java | 6 +++++- .../doric/src/main/java/pub/doric/DoricNativeDriver.java | 5 +++++ .../doric/src/main/java/pub/doric/DoricPanelFragment.java | 3 +-- .../doric/src/main/java/pub/doric/DoricSingleton.java | 2 +- .../main/java/pub/doric/loader/DoricJSLoaderManager.java | 4 ++-- doric-iOS/Pod/Classes/Doric.h | 2 ++ doric-iOS/Pod/Classes/Doric.m | 4 ++++ doric-iOS/Pod/Classes/DoricNativeDriver.h | 1 + doric-iOS/Pod/Classes/DoricNativeDriver.m | 5 +++++ doric-iOS/Pod/Classes/Loader/DoricJSLoaderManager.h | 2 +- 10 files changed, 27 insertions(+), 7 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/Doric.java b/doric-android/doric/src/main/java/pub/doric/Doric.java index 70f79d01..b25a5ea2 100644 --- a/doric-android/doric/src/main/java/pub/doric/Doric.java +++ b/doric-android/doric/src/main/java/pub/doric/Doric.java @@ -22,6 +22,7 @@ import com.facebook.soloader.SoLoader; import java.io.IOException; import java.util.Map; +import pub.doric.loader.DoricJSLoaderManager; import pub.doric.loader.IDoricJSLoader; /** @@ -65,7 +66,7 @@ public class Doric { * @param jsLoader Which added in global */ public static void addJSLoader(IDoricJSLoader jsLoader) { - DoricSingleton.getInstance().getJsLoaderManager().addJSLoader(jsLoader); + DoricSingleton.getInstance().getJSLoaderManager().addJSLoader(jsLoader); } public void setEnvironmentValue(Map value) { @@ -88,4 +89,7 @@ public class Doric { return DoricSingleton.getInstance().enableRenderSnapshot; } + public static DoricJSLoaderManager getJSLoaderManager() { + return DoricSingleton.getInstance().getJSLoaderManager(); + } } diff --git a/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java b/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java index 0106e705..c06c9c00 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java @@ -50,6 +50,11 @@ public class DoricNativeDriver implements IDoricDriver { mJSHandler = doricJSEngine.getJSHandler(); } + @Deprecated + public static DoricNativeDriver getInstance() { + return DoricSingleton.getInstance().getNativeDriver(); + } + @Override public AsyncResult invokeContextEntityMethod(final String contextId, final String method, final Object... args) { final AsyncResult asyncResult = new AsyncResult<>(); diff --git a/doric-android/doric/src/main/java/pub/doric/DoricPanelFragment.java b/doric-android/doric/src/main/java/pub/doric/DoricPanelFragment.java index 0222f42b..5dad9e49 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricPanelFragment.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricPanelFragment.java @@ -35,7 +35,6 @@ import java.util.concurrent.Callable; import pub.doric.async.AsyncCall; import pub.doric.async.AsyncResult; -import pub.doric.loader.DoricJSLoaderManager; import pub.doric.navbar.BaseDoricNavBar; import pub.doric.navigator.IDoricNavigator; import pub.doric.utils.DoricLog; @@ -198,7 +197,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator { final String alias = argument.getString("alias"); String source = argument.getString("source"); final String extra = argument.getString("extra"); - DoricSingleton.getInstance().getJsLoaderManager().loadJSBundle(source).setCallback(new AsyncResult.Callback() { + DoricSingleton.getInstance().getJSLoaderManager().loadJSBundle(source).setCallback(new AsyncResult.Callback() { @Override public void onResult(String result) { if (getActivity() == null) { diff --git a/doric-android/doric/src/main/java/pub/doric/DoricSingleton.java b/doric-android/doric/src/main/java/pub/doric/DoricSingleton.java index b1c7b6e1..0f9ee5fd 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricSingleton.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricSingleton.java @@ -77,7 +77,7 @@ public class DoricSingleton { } } - public DoricJSLoaderManager getJsLoaderManager() { + public DoricJSLoaderManager getJSLoaderManager() { return jsLoaderManager; } 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 ef3c7504..c977b24d 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 @@ -69,8 +69,8 @@ public class DoricJSLoaderManager { return ret; } - + @Deprecated public static DoricJSLoaderManager getInstance() { - return DoricSingleton.getInstance().getJsLoaderManager(); + return DoricSingleton.getInstance().getJSLoaderManager(); } } diff --git a/doric-iOS/Pod/Classes/Doric.h b/doric-iOS/Pod/Classes/Doric.h index e45ebff6..4abc31cd 100644 --- a/doric-iOS/Pod/Classes/Doric.h +++ b/doric-iOS/Pod/Classes/Doric.h @@ -59,4 +59,6 @@ + (BOOL)isEnableRenderSnapshot; + (void)setEnvironmentValue:(NSDictionary *)value; + ++ (DoricJSLoaderManager *)jsLoaderManager; @end \ No newline at end of file diff --git a/doric-iOS/Pod/Classes/Doric.m b/doric-iOS/Pod/Classes/Doric.m index e224d2d9..427ba551 100644 --- a/doric-iOS/Pod/Classes/Doric.m +++ b/doric-iOS/Pod/Classes/Doric.m @@ -51,4 +51,8 @@ + (BOOL)isEnableRenderSnapshot { + (void)setEnvironmentValue:(NSDictionary *)value { [DoricSingleton.instance setEnvironmentValue:value]; } + ++ (DoricJSLoaderManager *)jsLoaderManager { + return DoricSingleton.instance.jsLoaderManager; +} @end \ No newline at end of file diff --git a/doric-iOS/Pod/Classes/DoricNativeDriver.h b/doric-iOS/Pod/Classes/DoricNativeDriver.h index b2c180cd..58a0506e 100644 --- a/doric-iOS/Pod/Classes/DoricNativeDriver.h +++ b/doric-iOS/Pod/Classes/DoricNativeDriver.h @@ -32,6 +32,7 @@ typedef NS_ENUM(NSInteger, DoricQueueMode) { NS_ASSUME_NONNULL_BEGIN @interface DoricNativeDriver : NSObject ++ (instancetype)instance DEPRECATED_MSG_ATTRIBUTE("Do not use this api");; @end NS_ASSUME_NONNULL_END diff --git a/doric-iOS/Pod/Classes/DoricNativeDriver.m b/doric-iOS/Pod/Classes/DoricNativeDriver.m index 1b0a186e..fd92877d 100644 --- a/doric-iOS/Pod/Classes/DoricNativeDriver.m +++ b/doric-iOS/Pod/Classes/DoricNativeDriver.m @@ -25,6 +25,7 @@ #import "DoricConstant.h" #import "DoricContextManager.h" #import "DoricPerformanceProfile.h" +#import "DoricSingleton.h" @interface DoricNativeDriver () @property(nonatomic, strong) DoricJSEngine *jsExecutor; @@ -34,6 +35,10 @@ @implementation DoricNativeDriver @dynamic registry; ++ (instancetype)instance { + return DoricSingleton.instance.nativeDriver; +} + - (instancetype)init { if (self = [super init]) { _jsExecutor = [[DoricJSEngine alloc] init]; diff --git a/doric-iOS/Pod/Classes/Loader/DoricJSLoaderManager.h b/doric-iOS/Pod/Classes/Loader/DoricJSLoaderManager.h index 575acb94..1c376cce 100644 --- a/doric-iOS/Pod/Classes/Loader/DoricJSLoaderManager.h +++ b/doric-iOS/Pod/Classes/Loader/DoricJSLoaderManager.h @@ -25,7 +25,7 @@ #import "DoricAsyncResult.h" @interface DoricJSLoaderManager : NSObject -+ (instancetype)instance; ++ (instancetype)instance DEPRECATED_MSG_ATTRIBUTE("Use Doric.jsLoaderManager instead"); - (void)addJSLoader:(id )loader;