wjc
2025-04-09 87cd5df70918e6ba1af849c5f026d3719bfdb1ac
app/src/main/java/com/hdl/photovoltaic/HDLApp.java
@@ -41,6 +41,7 @@
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
import com.hdl.sdk.link.core.connect.HDLUdpConnect;
import com.hdl.sdk.link.core.utils.QueueUtils;
import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
import org.greenrobot.eventbus.EventBus;
@@ -90,14 +91,16 @@
        //预创建脚本json文件夹
        HdlFileLogic.getInstance().createHdlESLocalJsonDirectory();
        init();
    }
    public void getAppLanguage() {
        String language = UserConfigManage.getInstance().getCurrentAppLanguage();
        if (TextUtils.isEmpty(language)) {
            //从内存里面获取不到语言,获取当前系统的;
            String str = getResources().getConfiguration().locale.getCountry();
            if (str.equals("CN") || str.equals("TW")) {
            String str = getResources().getConfiguration().locale.getLanguage();
            if (str.equals(LocalManageUtil.zh)) {
                UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.zh);
            } else {
                UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.en);
@@ -180,6 +183,7 @@
        HDLLinkPMSdk.initWithAppKey(this, AppConfigManage.getAppKey(), AppConfigManage.getAppSecret(), AppConfigManage.getAPPRegionUrl());
        //2.设置打印
        HDLLinkPMSdk.setLogEnabled(isLogEnabled);
        if (TextUtils.isEmpty(UserConfigManage.getInstance().getCurrentAppLanguage())) {
            //默认配置接口请求语言是英文
            UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.en);
@@ -199,7 +203,7 @@
        HDLLinkPMUser.getInstance().setOnReloginListener(new IOnReloginListener() {
            @Override
            public void onReLogin(int type) {
                HdlLogLogic.print("退到登录界面---" + type, true);
                HdlLogLogic.print("监听到登录退出---" + type, true);
                //type:  0:正常退出   1:极光推送强制退出
                //收到登录处理通知,关闭所有页面并打开登录页面
                AppManagerUtils.getAppManager().finishAllActivity();
@@ -221,10 +225,10 @@
                if (mInfoMap != null) {
                    mInfoMap.clear();
                }
//                //断开mqtt连接
//                if (MqttRecvClient.getInstance() != null) {
//                    MqttRecvClient.getInstance().disConnect();
//                }
                //断开mqtt连接
                if (MqttRecvClient.getInstance() != null) {
                    MqttRecvClient.getInstance().disConnect();
                }
                //断开所有tcp连接且清空连接缓存
                // TODO: 10/10/23
//                TcpSocketBoot.stopAllConnectLinkGateway();
@@ -345,6 +349,7 @@
        });
    }
    /**
     * 初始化uni app mqtt
     */
@@ -362,6 +367,7 @@
        }
    }
    @Override
    protected void attachBaseContext(Context base) {
        MultiDex.install(base);
@@ -371,6 +377,23 @@
    /**
     * 支持中英文切换
     */
    public Context getAppLocaleContext(Context context) {
        try {
            Locale locale = new Locale(UserConfigManage.getInstance().getCurrentAppLanguage());
            Configuration configuration = context.getResources().getConfiguration();
            configuration.setLocale(locale);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                configuration.setLocales(new LocaleList(locale));
            }
            return context.createConfigurationContext(configuration);
        } catch (Exception e) {
            return context;
        }
    }
    /**
     * 支持中英文切换
     */
    public Context getAppLocaleContext() {
        try {
            Locale locale = new Locale(UserConfigManage.getInstance().getCurrentAppLanguage());