From 89e0f6ddd29ad4fb5947bfcea396ad4b55a6621f Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期五, 14 六月 2024 11:08:00 +0800
Subject: [PATCH] 2024年06月14日11:07:49

---
 app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java |   51 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 47 insertions(+), 4 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 8f214c8..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;
 
 
@@ -92,12 +93,14 @@
     private void removeCallBack() {
         DCUniMPSDK.getInstance().setUniMPOnCloseCallBack(null);
         DCUniMPSDK.getInstance().setOnUniMPEventCallBack(null);
+
     }
 
     /**
      * 鐩戝惉鐩稿叧鍥炶皟
      */
     private void registerCallBack() {
+        DCUniMPSDK.getInstance();
         //1.璁剧疆灏忕▼搴忚鍏抽棴浜嬩欢鐩戝惉
         DCUniMPSDK.getInstance().setUniMPOnCloseCallBack(new IUniMPOnCloseCallBack() {
             @Override
@@ -130,6 +133,8 @@
                 HdlLogLogic.print("鏀跺埌灏忕▼搴忛�氱煡    event=" + event);
                 //鏆傛椂閫氳繃杩欎釜澶勭悊灏忕▼搴忓悓鏃跺鏉$浉鍚岀殑璇锋眰
                 if (data == null) {
+                    HdlLogLogic.print("鏀跺埌灏忕▼搴忛�氱煡,data鏁版嵁涓簄ull銆�", true);
+
                     return;
                 }
 //                String key= MD5Utils.getMd5(event+data.toString());
@@ -150,6 +155,8 @@
                     //闄や簡缁熶竴澶勭悊锛屽墿浣欏叾瀹冪壒瀹氬満鏅殑浜嬩欢閫氱煡
                     if (onOtherUniMPEventCallBack != null) {
                         onOtherUniMPEventCallBack.onOtherUniMPEventReceive(appid, event, data, callback);
+                    } else {
+                        HdlLogLogic.print("鏀跺埌灏忕▼搴忛�氱煡,鍥炶皟浜嬩欢涓簄ull,鏃犳硶鍥炶皟浜嬩欢骞舵墽琛屼笟鍔¢�昏緫--->event=" + event + "\r\n" + "data=" + data, true);
                     }
                 }
             }
@@ -258,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");
@@ -273,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;//璁板綍褰撳墠灏忕▼搴�
@@ -280,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());
         }
     }
@@ -352,12 +395,12 @@
         if (mUniMPCaches.containsKey(uniAppId)) {
             if (mUniMPCaches.get(uniAppId) != null) {
                 mUniMPCaches.get(uniAppId).sendUniMPEvent(topic, data);
-                HdlLogLogic.print("鍙戦�侀�氱煡鎴愬姛锛歟vent锛�" + topic + " data锛�" + new Gson().toJson(data));
+                HdlLogLogic.print("Android--->閫氱煡---uni--->涓婚:" + topic + "--->鍙戦�佹暟鎹�:" + new Gson().toJson(data));
             } else {
-                HdlLogLogic.print("鍙戦�佸け璐ワ紝灏忕▼搴忓璞′负绌猴細" + uniAppId);
+                HdlLogLogic.print("Android--->閫氱煡---uni--->澶辫触--->灏忕▼搴忓璞′负绌�:" + uniAppId);
             }
         } else {
-            HdlLogLogic.print("鍙戦�佸け璐ワ紝鎵句笉鍒板搴旂殑灏忕▼搴忥細" + uniAppId);
+            HdlLogLogic.print("Android--->閫氱煡---uni--->澶辫触--->灏忕▼搴忓璞′负绌�:" + uniAppId);
         }
 
     }

--
Gitblit v1.8.0