From 8c9368faedcb4697895f25b9188d5f876b3f8b77 Mon Sep 17 00:00:00 2001 From: hxb <hxb@hdlchina.com.cn> Date: 星期二, 04 六月 2024 17:21:05 +0800 Subject: [PATCH] 优化打开小程序慢的问题 --- app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java | 39 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java index 6f5b2e7..626e270 100644 --- a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java +++ b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java @@ -3,6 +3,7 @@ import android.app.Application; import android.content.Context; import android.os.Environment; +import android.os.SystemClock; import android.text.TextUtils; @@ -264,6 +265,41 @@ * @param jsonObject 闄勫姞鏁版嵁 * @param callBack 鐩戝惉灏忕▼搴廜therUniMPEvent浜嬩欢 */ + public void openUniMPDelay(String uniAppId, String path, JSONObject jsonObject, IOnOtherUniMPEventCallBack callBack) { + if (TextUtils.isEmpty(uniAppId)) { + HdlThreadLogic.toast(mContext, "uni Id null"); + HdlLogLogic.print("灏忕▼搴廔D 涓嶈兘涓虹┖"); + return; + } + try { + setOnOtherUniMPEventCallBack(callBack); + uniMP = null; + if (TextUtils.isEmpty(path)) { + uniMP = DCUniMPSDK.getInstance().openUniMP(mContext, uniAppId); + } else { + UniMPOpenConfiguration uniMPOpenConfiguration = new UniMPOpenConfiguration(); + uniMPOpenConfiguration.path = path; + uniMPOpenConfiguration.extraData = jsonObject; + uniMPOpenConfiguration.splashClass=MySplashView.class; + uniMP = DCUniMPSDK.getInstance().openUniMP(mContext, uniAppId, uniMPOpenConfiguration); + } + //android14鏈変簺璁惧鏈夐棶棰橈紝闇�瑕佺瓑寰� + if (android.os.Build.VERSION.SDK_INT >= 34) { + if (TextUtils.isEmpty(mCurrentAppId)) { + //绗竴娆$敤瑕佷紤鐪� + SystemClock.sleep(1000); + } + } + mCurrentAppId = uniAppId;//璁板綍褰撳墠灏忕▼搴� + mUniMPCaches.put(uniMP.getAppid(), uniMP); + } catch (Exception e) { + e.printStackTrace(); + HdlThreadLogic.toast(HDLApp.getInstance(), R.string.uni_open_error); +// initDCUniMPSDK(HDLApp.getInstance()); + HdlLogLogic.print("鎵撳紑澶辫触===" + e.getMessage()); + } + } + public void openUniMP(String uniAppId, String path, JSONObject jsonObject, IOnOtherUniMPEventCallBack callBack) { if (TextUtils.isEmpty(uniAppId)) { HdlThreadLogic.toast(mContext, "uni Id null"); @@ -279,6 +315,7 @@ UniMPOpenConfiguration uniMPOpenConfiguration = new UniMPOpenConfiguration(); uniMPOpenConfiguration.path = path; uniMPOpenConfiguration.extraData = jsonObject; + uniMPOpenConfiguration.splashClass=MySplashView.class; uniMP = DCUniMPSDK.getInstance().openUniMP(mContext, uniAppId, uniMPOpenConfiguration); } mCurrentAppId = uniAppId;//璁板綍褰撳墠灏忕▼搴� @@ -286,7 +323,7 @@ } catch (Exception e) { e.printStackTrace(); HdlThreadLogic.toast(HDLApp.getInstance(), R.string.uni_open_error); - initDCUniMPSDK(HDLApp.getInstance()); +// initDCUniMPSDK(HDLApp.getInstance()); HdlLogLogic.print("鎵撳紑澶辫触===" + e.getMessage()); } } -- Gitblit v1.8.0