mac
2024-05-10 43c0a28db7e43959561036dbde0eb5cb37a7e324
app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java
@@ -10,12 +10,19 @@
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;
/**
 * 消息详情
@@ -71,23 +78,29 @@
                        viewBinding.messageInfoAlarmDeviceIn.rightContentTv.setText(mMessageBean.getDeviceDesc());
                        viewBinding.messageInfoAlarmRangeIn.rightContentTv.setText(mMessageBean.getEffectScopeDesc());
                        viewBinding.messageInfoPowerStationLocationIn.rightContentTv.setText(mMessageBean.getLocationAddress());
                        String date = TimeUtils.getDateTimestamp(mMessageBean.getCreateTime());
                        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("FAULT")) {
                        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("WARN")) {
                        } 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("EVENT")) {
                            type = "事件";
                            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);
                        if (mMessageBean.getStatus().equals(MessageStateType.processed)) {
                            //已经解决掉的隐藏
                            viewBinding.messageInfoBackTv.setVisibility(View.GONE);
                            viewBinding.messageInfoSolveTv.setVisibility(View.GONE);
                        }
                    }
                });
            }
@@ -101,26 +114,76 @@
    }
    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)) {
                    //改变缓存状态
                    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);
                    } else {
                        //除“故障”外,其他等级信息“已读”后,自动移出“发生中”列表并加入“历史记录”列表
                        HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed);
                        sendEventBus();
                    }
                }
                finish();
            }
        });
        //返回的事件
        viewBinding.messageInfoBackTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mMessageBean == null) {
                    finish();
                    return;
                }
                //未处理
                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);
                    } else {
                        //除“故障”外,其他等级信息“已读”后,自动移出“发生中”列表并加入“历史记录”列表
                        HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed);
                        sendEventBus();
                    }
                }
                finish();
            }
        });
        //已处理的事件
        viewBinding.messageInfoSolveTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                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);
                            sendEventBus();
                        }
                        finish();
                    }
@@ -136,6 +199,23 @@
    }
    /**
     * 通知出去外面更新数据
     */
    private void sendEventBus() {
        //通知已处理要更新数据
        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);
    }
    private void initView() {
        viewBinding.toolbarTopIn.topTitleTv.setText(R.string.message_alarm_info);
@@ -143,6 +223,12 @@
        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);