package com.hdl.photovoltaic.ui.message; 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.databinding.ActivityMessageInfoBinding; 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; /** * 消息详情 */ public class MessageInfoActivity extends CustomBaseActivity { ActivityMessageInfoBinding viewBinding; private MessageBean mMessageBean; private String mMsgId; @Override public Object getContentView() { viewBinding = ActivityMessageInfoBinding.inflate(getLayoutInflater()); return viewBinding.getRoot(); } @Override public void onBindView(Bundle savedInstanceState) { setNotificationBarBackgroundColor(CustomColor.white); setStatusBarTextColor(); try { mMsgId = getIntent().getStringExtra("msgId"); } catch (Exception ignored) { } //初始化 initView(); //初始化界面监听器 initEvent(); //读取数据 readData(); } private void readData() { // showLoading(); HdlMessageLogic.getInstance().getMessageInfo(mMsgId, new CloudCallBeak() { @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.getDateTimestamp(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")) { type = _mActivity.getString(R.string.my_power_station_malfunction); drawable = AppCompatResources.getDrawable(_mActivity, R.drawable.alarm_e34343); } else if (mMessageBean.getType().equals("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); } viewBinding.messageInfoAlarmStateTv.setText(type); viewBinding.messageInfoAlarmStateTv.setBackground(drawable); } }); } @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) { finish(); } }); viewBinding.messageInfoBackTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); viewBinding.messageInfoSolveTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { HdlMessageLogic.getInstance().getMessageMessageSolve(mMsgId, new CloudCallBeak() { @Override public void onSuccess(Boolean obj) { finish(); } @Override public void onFailure(HDLException e) { HdlThreadLogic.toast(_mActivity, e); } }); } }); } 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)); 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(""); } }