mac
2024-07-16 3ec7de773bff5582411c6f1f659d35cf8fb1734a
app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java
@@ -8,9 +8,11 @@
import com.google.gson.Gson;
import com.hdl.linkpm.sdk.user.HDLLinkPMUser;
import com.hdl.photovoltaic.HDLApp;
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.config.AppConfigManage;
import com.hdl.photovoltaic.enums.LowerTagType;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
@@ -119,7 +121,8 @@
                //小程序被关闭了通知给原生
                BaseEventBus baseEventBus = new BaseEventBus();
                baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE);
                baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE);
                baseEventBus.setType(LowerTagType.power_station.toString());
                EventBus.getDefault().post(baseEventBus);
            }
@@ -156,6 +159,8 @@
                    if (onOtherUniMPEventCallBack != null) {
                        onOtherUniMPEventCallBack.onOtherUniMPEventReceive(appid, event, data, callback);
                    } else {
                        //有可能是系统回收掉activity到知道回调为null,这样情况下强制返回登录界面;
                        HDLLinkPMUser.getInstance().logout(0);
                        HdlLogLogic.print("收到小程序通知,回调事件为null,无法回调事件并执行业务逻辑--->event=" + event + "\r\n" + "data=" + data, true);
                    }
                }
@@ -256,16 +261,7 @@
        return true;
    }
    /**
     * 打开小程序
     *
     * @param uniAppId   小程序ID
     * @param path       指定路径
     *                   例:pages/component/scroll-view/scroll-view?a=1&b=2&c=3
     * @param jsonObject 附加数据
     * @param callBack   监听小程序OtherUniMPEvent事件
     */
    public void openUniMPDelay(String uniAppId, String path, JSONObject jsonObject, IOnOtherUniMPEventCallBack callBack) {
    public void openUniMP(String uniAppId, String path, JSONObject jsonObject, IOnOtherUniMPEventCallBack callBack) {
        if (TextUtils.isEmpty(uniAppId)) {
            HdlThreadLogic.toast(mContext, "uni Id null");
            HdlLogLogic.print("小程序ID 不能为空");
@@ -289,34 +285,6 @@
                    //第一次用要休眠
                    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");
            HdlLogLogic.print("小程序ID 不能为空");
            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);
            }
            mCurrentAppId = uniAppId;//记录当前小程序
            mUniMPCaches.put(uniMP.getAppid(), uniMP);