From b75795836a851a13e54cc4efb597262fb448217c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 08 五月 2024 15:22:01 +0800
Subject: [PATCH] 2024年05月08日15:21:54

---
 app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java |  166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 164 insertions(+), 2 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 df4bbc6..80d727b 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
@@ -1,12 +1,29 @@
 package com.hdl.photovoltaic.ui.message;
 
 
+import android.annotation.SuppressLint;
+import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.view.View;
 
+import androidx.appcompat.content.res.AppCompatResources;
+
+import com.hdl.linkpm.sdk.core.exception.HDLException;
 import com.hdl.photovoltaic.R;
 import com.hdl.photovoltaic.base.CustomBaseActivity;
+import com.hdl.photovoltaic.config.ConstantManage;
+import com.hdl.photovoltaic.config.UserConfigManage;
 import com.hdl.photovoltaic.databinding.ActivityMessageInfoBinding;
+import com.hdl.photovoltaic.enums.MessageAlarmStateType;
+import com.hdl.photovoltaic.enums.MessageStateType;
+import com.hdl.photovoltaic.listener.CloudCallBeak;
+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 org.greenrobot.eventbus.EventBus;
 
 /**
  * 娑堟伅璇︽儏
@@ -14,6 +31,10 @@
 public class MessageInfoActivity extends CustomBaseActivity {
 
     ActivityMessageInfoBinding viewBinding;
+
+    private MessageBean mMessageBean;
+
+    private String mMsgId;
 
     @Override
     public Object getContentView() {
@@ -25,6 +46,11 @@
     public void onBindView(Bundle savedInstanceState) {
         setNotificationBarBackgroundColor(CustomColor.white);
         setStatusBarTextColor();
+        try {
+            mMsgId = getIntent().getStringExtra("msgId");
+        } catch (Exception ignored) {
+        }
+
         //鍒濆鍖�
         initView();
         //鍒濆鍖栫晫闈㈢洃鍚櫒
@@ -34,32 +60,156 @@
     }
 
     private void readData() {
+
+//        showLoading();
+        HdlMessageLogic.getInstance().getMessageInfo(mMsgId, new CloudCallBeak<MessageBean>() {
+            @Override
+            public void onSuccess(MessageBean msg) {
+                HdlThreadLogic.runMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+//                        hideLoading();
+                        if (msg == null) {
+                            return;
+                        }
+                        mMessageBean = msg;
+
+                        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);
+
+                        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.event);
+                            drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.alarm_ffb300);
+                        }
+                        viewBinding.messageInfoAlarmStateTv.setText(type);
+                        viewBinding.messageInfoAlarmStateTv.setBackground(drawable);
+
+                        if (mMessageBean.getStatus().equals(MessageStateType.processed)) {
+                            //宸茬粡瑙e喅鎺夌殑闅愯棌
+                            viewBinding.messageInfoBackTv.setVisibility(View.GONE);
+                            viewBinding.messageInfoSolveTv.setVisibility(View.GONE);
+                        }
+                    }
+                });
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+//                hideLoading();
+                HdlThreadLogic.toast(_mActivity, e);
+            }
+        });
     }
 
     private void initEvent() {
+        //鍚庨��鐨勪簨浠�
         viewBinding.toolbarTopIn.topBackBtn.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                if (mMessageBean == null) {
+                    finish();
+                    return;
+                }
+                //鏈鐞�
+                if (mMessageBean.getStatus().equals(MessageStateType.untreated)) {
+                    BaseEventBus baseEventBus = new BaseEventBus();
+                    baseEventBus.setTopic(ConstantManage.message_function_push_post);
+                    //鏀瑰彉缂撳瓨鐘舵��
+                    if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) {
+                        HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.untreated);
+                        baseEventBus.setType(MessageStateType.untreated);
+                    } else {
+                        //闄も�滄晠闅溾�濆锛屽叾浠栫瓑绾т俊鎭�滃凡璇烩�濆悗锛岃嚜鍔ㄧЩ鍑衡�滃彂鐢熶腑鈥濆垪琛ㄥ苟鍔犲叆鈥滃巻鍙茶褰曗�濆垪琛�
+                        HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed);
+                        baseEventBus.setType(MessageStateType.processed);
+                    }
+                    EventBus.getDefault().post(baseEventBus);
+                }
                 finish();
             }
         });
-
+        //杩斿洖鐨勪簨浠�
         viewBinding.messageInfoBackTv.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                if (mMessageBean == null) {
+                    finish();
+                    return;
+                }
+                //鏈鐞�
+                if (mMessageBean.getStatus().equals(MessageStateType.untreated)) {
+                    BaseEventBus baseEventBus = new BaseEventBus();
+                    baseEventBus.setTopic(ConstantManage.message_function_push_post);
+                    //鏀瑰彉缂撳瓨鐘舵��
+                    if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) {
+                        HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.untreated);
+                        baseEventBus.setType(MessageStateType.untreated);
+                    } else {
+                        //闄も�滄晠闅溾�濆锛屽叾浠栫瓑绾т俊鎭�滃凡璇烩�濆悗锛岃嚜鍔ㄧЩ鍑衡�滃彂鐢熶腑鈥濆垪琛ㄥ苟鍔犲叆鈥滃巻鍙茶褰曗�濆垪琛�
+                        HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed);
+                        baseEventBus.setType(MessageStateType.processed);
+                    }
+                    EventBus.getDefault().post(baseEventBus);
+                }
                 finish();
             }
         });
 
+        //宸插鐞嗙殑浜嬩欢
         viewBinding.messageInfoSolveTv.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                finish();
+                HdlMessageLogic.getInstance().getMessageMessageSolve(mMsgId, new CloudCallBeak<Boolean>() {
+                    @Override
+                    public void onSuccess(Boolean obj) {
+                        if (mMessageBean == null) {
+                            return;
+                        }
+                        //鏈鐞�
+                        if (mMessageBean.getStatus().equals(MessageStateType.untreated)) {
+                            HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed);
+
+                            //閫氱煡宸插鐞嗚鏇存柊鏁版嵁
+                            BaseEventBus processedBus = new BaseEventBus();
+                            processedBus.setTopic(ConstantManage.message_function_push_post);
+                            processedBus.setType(MessageStateType.processed);
+                            EventBus.getDefault().post(processedBus);
+                            //閫氱煡鏈鐞嗚鏇存柊鏁版嵁
+                            BaseEventBus untreatedBus = new BaseEventBus();
+                            untreatedBus.setTopic(ConstantManage.message_function_push_post);
+                            untreatedBus.setType(MessageStateType.untreated);
+                            EventBus.getDefault().post(untreatedBus);
+                        }
+                        finish();
+
+
+                    }
+
+                    @Override
+                    public void onFailure(HDLException e) {
+                        HdlThreadLogic.toast(_mActivity, e);
+                    }
+                });
+
             }
         });
 
 
     }
+
 
     private void initView() {
 
@@ -68,10 +218,22 @@
         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.messageInfoAlarmContentIn.leftTitleTv.setText(R.string.messagealarm_details_content);
         viewBinding.messageInfoAlarmDeviceIn.leftTitleTv.setText(R.string.messagealarm_details_device);
         viewBinding.messageInfoAlarmRangeIn.leftTitleTv.setText(R.string.message_alarm_detailsaffect_region);
         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("");
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0