| | |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.enums.DeviceType; |
| | | import com.hdl.photovoltaic.enums.MessageAlarmStateType; |
| | | import com.hdl.photovoltaic.ui.bean.MessageBean; |
| | | import com.hdl.photovoltaic.utils.TimeUtils; |
| | |
| | | public void onBindViewHolder(@NonNull MessageCenterListAdapter.MyViewHolder holder, int position) { |
| | | MessageBean messageBean = this.mList.get(position); |
| | | holder.item_content_tv.setText(messageBean.getTitle()); |
| | | holder.item_home_name_tv.setText(messageBean.getHomeName()); |
| | | String strName = getDeviceTypeStr(messageBean.getDeviceType()) + "(" + messageBean.getDeviceDesc() + ")"; |
| | | holder.item_home_name_tv.setText(strName); |
| | | String date = TimeUtils.getTimeFromTimestamp(messageBean.getCreateTime()); |
| | | holder.item_time_tv.setText(date); |
| | | String type = "";//FAULT:故障,WARN:告警,EVENT:事件 |
| | | Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_ffb300); |
| | | Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_satte_ffb300); |
| | | if (messageBean.getType().equals(MessageAlarmStateType.fault)) { |
| | | type = mContext.getString(R.string.my_power_station_malfunction); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_fff55252); |
| | | } else if (messageBean.getType().equals(MessageAlarmStateType.warn)) { |
| | | type = mContext.getString(R.string.alarm_all_grade_warning); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_ffb300); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_satte_ffb300); |
| | | } else if (messageBean.getType().equals(MessageAlarmStateType.event)) { |
| | | type = mContext.getString(R.string.loading_title_tip); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_b9b9b9); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ffb9b9b9); |
| | | } |
| | | holder.item_estate_tv.setText(type); |
| | | holder.item_estate_tv.setBackground(drawable); |
| | |
| | | notifyDataSetChanged(); |
| | | } |
| | | |
| | | /** |
| | | * 通过枚举转换设备类型的字符 |
| | | * |
| | | * @param deviceType //设备类型(INV : 逆变器, BMS : BMS控制盒, BATTERY : 电池单元) |
| | | * @return 设备类型 |
| | | */ |
| | | private String getDeviceTypeStr(String deviceType) { |
| | | switch (deviceType) { |
| | | case DeviceType.inv: |
| | | return mContext.getString(R.string.alarm_all_device_inverter); |
| | | case DeviceType.bms: |
| | | return mContext.getString(R.string.alarm_all_device_bms); |
| | | case DeviceType.battery: |
| | | return mContext.getString(R.string.alarm_all_device_battery_cell); |
| | | default: |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | |
| | | public void setNoOnclickListener(OnclickListener onClickListener) { |
| | | this.mOnClickListener = onClickListener; |
| | |
| | | public interface OnclickListener { |
| | | void onClick(int position, MessageBean messageBean); |
| | | } |
| | | |
| | | |
| | | } |