wjc
20 小时以前 2f5411b86c59706d31f6ec7de629d8f860725e46
app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
@@ -16,9 +16,12 @@
import android.os.SystemClock;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.hdl.linkpm.sdk.core.exception.HDLException;
@@ -41,17 +44,22 @@
import com.hdl.photovoltaic.other.HdlMessageLogic;
import com.hdl.photovoltaic.other.HdlMqttLogic;
import com.hdl.photovoltaic.other.HdlOtaLogic;
import com.hdl.photovoltaic.other.HdlPushLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.push.PushMessageInfoBean;
import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
import com.hdl.photovoltaic.ui.bean.MessageBean;
import com.hdl.photovoltaic.ui.bean.OidBean;
import com.hdl.photovoltaic.ui.bean.UnCountBean;
import com.hdl.photovoltaic.ui.home.HomePageFragment;
import com.hdl.photovoltaic.ui.me.MeFragment;
import com.hdl.photovoltaic.ui.message.MessageHouseFragment;
import com.hdl.photovoltaic.ui.message.MessageInfoActivity;
import com.hdl.photovoltaic.ui.powerstation.HouseAndDeviceFragment;
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.uni.HDLUniMPSDKManager;
import com.hdl.photovoltaic.utils.AppManagerUtils;
import com.hdl.photovoltaic.utils.GPSManagerUtils;
import com.hdl.photovoltaic.utils.PermissionUtils;
@@ -75,6 +83,7 @@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import cn.jpush.android.api.JPushInterface;
@@ -114,10 +123,14 @@
        this.registerAllTopicsListener();
        //初始化mqtt客户端
        this.initMqttClient();
        //上传极光注册ID到云端
        this.pushTokens();
        //点击极光通知栏消息进来
        this.clickJpushNotificationMessage();
//        //上传极光注册ID到云端 隐藏2025-11-21 11:52:27
//        this.pushTokens();
        //上传推动令牌到云端(谷歌FCM推送)
        this.sendPushTokenToServer(UserConfigManage.getInstance().getPushToken());
//        //点击极光通知栏消息进来
//        this.clickJpushNotificationMessage();
        //点击通知栏消息进来
        this.OpenSpecifiedPage(getIntent(), "onBindView");
        //初始化权限
        this.requestPermissions();
        //读取消息未读数量
@@ -128,6 +141,36 @@
    }
    /**
     * 点击通知栏消息进来
     */
    private void OpenSpecifiedPage(Intent intent, String tag) {
        Log.d("==========", tag);
        try {
            String data = getIntentExpantData(intent);
            if (TextUtils.isEmpty(data)) {
                return;
            }
            PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data);
            if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) {
                return;
            }
            MessageBean messageBean = new MessageBean();
            messageBean.setMsgId(Long.valueOf(pushMessageInfoBean.getMsgId()));
            Intent intentMessageInfoActivity = new Intent();
            intentMessageInfoActivity.setClass(_mActivity, MessageInfoActivity.class);
            intentMessageInfoActivity.putExtra("messageBean", JSONObject.toJSONString(messageBean));
            startActivity(intentMessageInfoActivity);
            this.clickNotificationMessageTab();
            if (null != HDLUniMPSDKManager.getInstance().getUniMP()) {
                Log.d("HDLUniMPSDKManager.getInstance().getUniMP()", "HDLUniMPSDKManager.getInstance().getUniMP()");
                HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP();
            }
        } catch (Exception e) {
            Log.d("错误", " " + e.getMessage());
        }
    }
    /**
     * 初始化Fragment
@@ -287,7 +330,7 @@
                        public void onSuccess(String pushId) {
                            if (!TextUtils.isEmpty(pushId)) {
                                UserConfigManage.getInstance().setRegistrationID(finalRegistrationID);
                                UserConfigManage.getInstance().setPushToken(finalRegistrationID);
                                UserConfigManage.getInstance().setPushId(pushId);
                                UserConfigManage.getInstance().Save();
                            }
@@ -306,6 +349,34 @@
                }
            }
        });
    }
    /**
     * 上传 token 到服务器
     *
     * @param token 令牌
     */
    private void sendPushTokenToServer(final String token) {
        if (TextUtils.isEmpty(token)) {
            return;
        }
        HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
            @Override
            public void onSuccess(String pushId) {
                if (!TextUtils.isEmpty(pushId)) {
                    UserConfigManage.getInstance().setToken(token);
                    UserConfigManage.getInstance().setPushId(pushId);
                    UserConfigManage.getInstance().Save();
                }
                HdlLogLogic.print("添加令牌到云端 PushToken:" + UserConfigManage.getInstance().getPushToken() + " pushId:" + pushId, true);
            }
            @Override
            public void onFailure(HDLException e) {
                HdlLogLogic.print("添加令牌到云端失败 PushToken:" + UserConfigManage.getInstance().getPushToken() + " 错误:" + e.getMessage(), true);
            }
        });
    }
@@ -410,6 +481,7 @@
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d("BPowerStationActivity", "onDestroy");
        HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack();
        //移除监听
        HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener);
@@ -742,6 +814,9 @@
                bottomViewChangeOfStyle();
                showFragment();
            }
        } else if (event.getTopic().contains(ConstantManage.refresh_push_token)) {
            //pushToken更新
            sendPushTokenToServer(UserConfigManage.getInstance().getPushToken());
        }
    }
@@ -794,19 +869,27 @@
        });
    }
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        //AndroidManifest.xml 需要添加启动模式android:launchMode="singleTask"才执行这个方法
        OpenSpecifiedPage(intent, "onNewIntent");
    }
    /**
     * 点击极光通知栏消息进来
     * 点击通知栏消息进来,默认选择消息模块
     */
    private void clickJpushNotificationMessage() {
        Intent intent = getIntent();
        if (intent != null) {
            String key = intent.getStringExtra("skip");
            if (key != null) {
    private void clickNotificationMessageTab() {
                //触发消息点击事件
                viewBinding.myMessageBottomIl2.clickTv.performClick();
            }
        }
//        if (currentFragmentIndex == 2) {
//            return;
//        }
//        currentFragmentIndex = 2;
//        bottomViewChangeOfStyle();
//        showFragment();
//        HdlCommonLogic.lowerTagType = LowerTagType.message;
//        HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, HomepageTitleTabSwitch.message.toString());
    }
@@ -900,5 +983,29 @@
        }
    }
    /**
     * 处理从通知点击带来的数据,这里获取数据,然后透传给主界面做处理
     *
     * @return 返回附加数据
     */
    private String getIntentExpantData(Intent intent) {
        try {
            if (intent == null) {
                return "";
            }
            // 处理从通知点击带来的数据,这里获取数据,然后透传给主界面做处理
            if (intent.getExtras() != null) {
                for (String key : intent.getExtras().keySet()) {
                    if (key.equals("pushData")) {
                        return Objects.requireNonNull(intent.getExtras().get(key)).toString();
                    }
                }
            }
        } catch (Exception e) {
            return "";
        }
        return "";
    }
}