From 8814f3f0828e6ac652a29cc9de9f971fd55bca5b Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 07 五月 2025 14:54:42 +0800
Subject: [PATCH] 2025年05月07日14:54:39

---
 app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java |  142 +++++++++++++++++++++++++++++------------------
 1 files changed, 88 insertions(+), 54 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java
index 4cf04f1..c4c25a6 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java
@@ -4,9 +4,11 @@
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.view.View;
+import android.widget.TextView;
 
 import androidx.appcompat.content.res.AppCompatResources;
 
+import com.google.gson.Gson;
 import com.hdl.linkpm.sdk.core.exception.HDLException;
 import com.hdl.photovoltaic.R;
 import com.hdl.photovoltaic.base.CustomBaseActivity;
@@ -16,11 +18,13 @@
 import com.hdl.photovoltaic.enums.MessageAlarmStateType;
 import com.hdl.photovoltaic.enums.MessageStateType;
 import com.hdl.photovoltaic.listener.CloudCallBeak;
+import com.hdl.photovoltaic.other.HdlCommonLogic;
 import com.hdl.photovoltaic.other.HdlMessageLogic;
 import com.hdl.photovoltaic.other.HdlThreadLogic;
 import com.hdl.photovoltaic.ui.bean.MessageBean;
 import com.hdl.photovoltaic.utils.TimeUtils;
 import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
+import com.jaeger.library.StatusBarUtil;
 
 import org.greenrobot.eventbus.EventBus;
 
@@ -33,7 +37,6 @@
 
     private MessageBean mMessageBean;
 
-    private String mMsgId;
 
     @Override
     public Object getContentView() {
@@ -43,10 +46,14 @@
 
     @Override
     public void onBindView(Bundle savedInstanceState) {
-        setNotificationBarBackgroundColor(CustomColor.white);
-        setStatusBarTextColor();
+       setStatusBarTranslucent();
+        getWindow().setNavigationBarColor(getColor(R.color.text_FF000000));
         try {
-            mMsgId = getIntent().getStringExtra("msgId");
+            String json = getIntent().getStringExtra("messageBean");
+            mMessageBean = new Gson().fromJson(json, MessageBean.class);
+            if (mMessageBean == null) {
+                mMessageBean = new MessageBean();
+            }
         } catch (Exception ignored) {
         }
 
@@ -61,7 +68,7 @@
     private void readData() {
 
 //        showLoading();
-        HdlMessageLogic.getInstance().getMessageInfo(mMsgId, new CloudCallBeak<MessageBean>() {
+        HdlMessageLogic.getInstance().getMessageInfo(mMessageBean.getMsgId().toString(), new CloudCallBeak<MessageBean>() {
             @Override
             public void onSuccess(MessageBean msg) {
                 HdlThreadLogic.runMainThread(new Runnable() {
@@ -80,24 +87,16 @@
                         viewBinding.messageInfoPowerStationLocationIn.rightContentTv.setText(mMessageBean.getLocationAddress());
                         String date = TimeUtils.getTimeFromTimestamp(mMessageBean.getCreateTime());
                         viewBinding.messageInfoAlarmTimeIn.rightContentTv.setText(date);
-
-                        String type = "";//FAULT:鏁呴殰,WARN:鍛婅,EVENT:浜嬩欢
-                        Drawable drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.alarm_ffb300);
-                        if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) {
-                            type = _mActivity.getString(R.string.my_power_station_malfunction);
-                            drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.alarm_e34343);
-                        } else if (mMessageBean.getType().equals(MessageAlarmStateType.warn)) {
-                            type = _mActivity.getString(R.string.message_alarm);
-                            drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.alarm_ffb300);
-                        } else if (mMessageBean.getType().equals(MessageAlarmStateType.event)) {
-                            type = _mActivity.getString(R.string.loading_title_tip);
-                            drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.state_b9b9b9);
-                        }
-                        viewBinding.messageInfoAlarmStateTv.setText(type);
-                        viewBinding.messageInfoAlarmStateTv.setBackground(drawable);
+                        stateStyle(viewBinding.messageInfoAlarmStateTv);
 
                         if (mMessageBean.getStatus().equals(MessageStateType.processed)) {
                             //宸茬粡瑙e喅鎺夌殑闅愯棌
+                            viewBinding.messageInfoBackTv.setVisibility(View.GONE);
+                            viewBinding.messageInfoSolveTv.setVisibility(View.GONE);
+                        } else {
+                            if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) {
+                                return;
+                            }
                             viewBinding.messageInfoBackTv.setVisibility(View.GONE);
                             viewBinding.messageInfoSolveTv.setVisibility(View.GONE);
                         }
@@ -115,7 +114,7 @@
 
     private void initEvent() {
         //鍚庨��鐨勪簨浠�
-        viewBinding.toolbarTopIn.topBackBtn.setOnClickListener(new View.OnClickListener() {
+        viewBinding.toolbarTopRl.topBackLl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 if (mMessageBean == null) {
@@ -124,14 +123,11 @@
                 }
                 //鏈鐞�
                 if (mMessageBean.getStatus().equals(MessageStateType.untreated)) {
-
                     //鏀瑰彉缂撳瓨鐘舵��
                     if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) {
                         HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.untreated);
-                        BaseEventBus baseEventBus = new BaseEventBus();
-                        baseEventBus.setTopic(ConstantManage.message_function_push_post);
-                        baseEventBus.setType(MessageStateType.untreated);
-                        EventBus.getDefault().post(baseEventBus);
+                        //閫氱煡鏈鐞嗚鏇存柊鏁版嵁
+                        HdlCommonLogic.getInstance().postEventBus(ConstantManage.message_function_push_post, MessageStateType.untreated);
                     } else {
                         //闄も�滄晠闅溾�濆锛屽叾浠栫瓑绾т俊鎭�滃凡璇烩�濆悗锛岃嚜鍔ㄧЩ鍑衡�滃彂鐢熶腑鈥濆垪琛ㄥ苟鍔犲叆鈥滃巻鍙茶褰曗�濆垪琛�
                         HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed);
@@ -155,10 +151,8 @@
                     //鏀瑰彉缂撳瓨鐘舵��
                     if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) {
                         HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.untreated);
-                        BaseEventBus baseEventBus = new BaseEventBus();
-                        baseEventBus.setTopic(ConstantManage.message_function_push_post);
-                        baseEventBus.setType(MessageStateType.untreated);
-                        EventBus.getDefault().post(baseEventBus);
+                        //閫氱煡鏈鐞嗚鏇存柊鏁版嵁
+                        HdlCommonLogic.getInstance().postEventBus(ConstantManage.message_function_push_post, MessageStateType.untreated);
                     } else {
                         //闄も�滄晠闅溾�濆锛屽叾浠栫瓑绾т俊鎭�滃凡璇烩�濆悗锛岃嚜鍔ㄧЩ鍑衡�滃彂鐢熶腑鈥濆垪琛ㄥ苟鍔犲叆鈥滃巻鍙茶褰曗�濆垪琛�
                         HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed);
@@ -173,7 +167,7 @@
         viewBinding.messageInfoSolveTv.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlMessageLogic.getInstance().getMessageMessageSolve(mMsgId, new CloudCallBeak<Boolean>() {
+                HdlMessageLogic.getInstance().getMessageMessageSolve(mMessageBean.getMsgId().toString(), new CloudCallBeak<Boolean>() {
                     @Override
                     public void onSuccess(Boolean obj) {
                         if (mMessageBean == null) {
@@ -204,30 +198,16 @@
      */
     private void sendEventBus() {
         //閫氱煡宸插鐞嗚鏇存柊鏁版嵁
-        BaseEventBus processedBus = new BaseEventBus();
-        processedBus.setTopic(ConstantManage.message_function_push_post);
-        processedBus.setType(MessageStateType.processed);
-        EventBus.getDefault().post(processedBus);
+        HdlCommonLogic.getInstance().postEventBus(ConstantManage.message_function_push_post, MessageStateType.processed);
         //閫氱煡鏈鐞嗚鏇存柊鏁版嵁
-        BaseEventBus untreatedBus = new BaseEventBus();
-        untreatedBus.setTopic(ConstantManage.message_function_push_post);
-        untreatedBus.setType(MessageStateType.untreated);
-        EventBus.getDefault().post(untreatedBus);
+        HdlCommonLogic.getInstance().postEventBus(ConstantManage.message_function_push_post, MessageStateType.untreated);
     }
 
 
     private void initView() {
 
-        viewBinding.toolbarTopIn.topTitleTv.setText(R.string.message_alarm_info);
-        viewBinding.toolbarTopIn.topTitleTv.setTextColor(getResources().getColor(R.color.text_030D1C, null));
-        viewBinding.toolbarTopIn.topBackBtn.setVisibility(View.VISIBLE);
-        viewBinding.toolbarTopIn.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFFFFFFF, null));
-
-        if (!UserConfigManage.getInstance().isBAccount()) {
-            viewBinding.messageInfoBackTv.setTextColor(getColor(R.color.text_38C494));
-            viewBinding.messageInfoBackTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.fillet_line_38c494));
-            viewBinding.messageInfoSolveTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.checked_38c494));
-        }
+        viewBinding.toolbarTopRl.topTitleTv.setText(R.string.message_alarm_info);
+        viewBinding.toolbarTopRl.topBackLl.setVisibility(View.VISIBLE);
 
         viewBinding.messageInfoAlarmContentIn.leftTitleTv.setText(R.string.messagealarm_details_content);
         viewBinding.messageInfoAlarmDeviceIn.leftTitleTv.setText(R.string.messagealarm_details_device);
@@ -235,10 +215,64 @@
         viewBinding.messageInfoPowerStationLocationIn.leftTitleTv.setText(R.string.message_alarm_detailspower_station_location);
         viewBinding.messageInfoAlarmTimeIn.leftTitleTv.setText(R.string.message_alarm_details_time);
 
-        viewBinding.messageInfoAlarmContentIn.rightContentTv.setText("");
-        viewBinding.messageInfoAlarmDeviceIn.rightContentTv.setText("");
-        viewBinding.messageInfoAlarmRangeIn.rightContentTv.setText("");
-        viewBinding.messageInfoPowerStationLocationIn.rightContentTv.setText("");
-        viewBinding.messageInfoAlarmTimeIn.rightContentTv.setText("");
+        viewBinding.messageInfoHomeNameTv.setText(mMessageBean.getHomeName());
+        viewBinding.messageInfoAlarmContentIn.rightContentTv.setText(mMessageBean.getTitle());
+        viewBinding.messageInfoAlarmDeviceIn.rightContentTv.setText(mMessageBean.getDeviceDesc());
+        viewBinding.messageInfoAlarmRangeIn.rightContentTv.setText(mMessageBean.getEffectScopeDesc());
+        viewBinding.messageInfoPowerStationLocationIn.rightContentTv.setText(mMessageBean.getLocationAddress());
+        String date = TimeUtils.getTimeFromTimestamp(mMessageBean.getCreateTime());
+        viewBinding.messageInfoAlarmTimeIn.rightContentTv.setText(date);
+        stateStyle(viewBinding.messageInfoAlarmStateTv);
+
+
+        if (mMessageBean.getStatus().equals(MessageStateType.untreated) && mMessageBean.getType().equals(MessageAlarmStateType.fault)) {
+            //鍙戠敓涓殑娑堟伅涓旀槸鏁呴殰鎵嶈鏄剧ず
+            viewBinding.messageInfoWorkOut.setVisibility(View.VISIBLE);
+        }
+    }
+
+
+    /**
+     * 鐘舵�佹牱寮�
+     *
+     * @param textView 缁勪欢
+     */
+    private void stateStyle(TextView textView) {
+        String type = "";//FAULT:鏁呴殰,WARN:鍛婅,EVENT:浜嬩欢
+        Drawable drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.device_satte_ffb300);
+        if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) {
+            type = _mActivity.getString(R.string.my_power_station_malfunction);
+            drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.device_state_fff55252);
+        } else if (mMessageBean.getType().equals(MessageAlarmStateType.warn)) {
+            type = _mActivity.getString(R.string.message_alarm);
+            drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.device_satte_ffb300);
+        } else if (mMessageBean.getType().equals(MessageAlarmStateType.event)) {
+            type = _mActivity.getString(R.string.loading_title_tip);
+            drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.device_state_ffb9b9b9);
+        }
+//        textView.setText(type);
+        textView.setBackground(drawable);
+    }
+
+    @Override
+    public void onBackPressed() {
+        super.onBackPressed();
+        if (mMessageBean == null) {
+            return;
+        }
+        //鏈鐞�
+        if (mMessageBean.getStatus().equals(MessageStateType.untreated)) {
+            //鏀瑰彉缂撳瓨鐘舵��
+            if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) {
+                HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.untreated);
+                //閫氱煡鏈鐞嗚鏇存柊鏁版嵁
+                HdlCommonLogic.getInstance().postEventBus(ConstantManage.message_function_push_post, MessageStateType.untreated);
+            } else {
+                //闄も�滄晠闅溾�濆锛屽叾浠栫瓑绾т俊鎭�滃凡璇烩�濆悗锛岃嚜鍔ㄧЩ鍑衡�滃彂鐢熶腑鈥濆垪琛ㄥ苟鍔犲叆鈥滃巻鍙茶褰曗�濆垪琛�
+                HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed);
+                sendEventBus();
+            }
+
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0