| | |
| | | package com.hdl.photovoltaic.ui.message; |
| | | |
| | | import android.os.Bundle; |
| | | import android.view.ViewGroup; |
| | | |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseFragment; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.config.ConstantManage; |
| | | import com.hdl.photovoltaic.databinding.FragmentMessageAllBinding; |
| | | import com.hdl.photovoltaic.ui.adapter.LanguageAdapter; |
| | | import com.hdl.photovoltaic.databinding.FragmentMessageBinding; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.ui.adapter.MessageAdapter; |
| | | import com.hdl.photovoltaic.ui.bean.MessageBean; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | |
| | | private FragmentMessageAllBinding viewBinding; |
| | | |
| | | private MessageAdapter messageAdapter; |
| | | private MessageAdapter messageAllAdapter; |
| | | |
| | | private List<MessageBean> mList; |
| | | private final List<MessageBean> mList = new ArrayList<>(); |
| | | |
| | | @Override |
| | | public Object getContentView() { |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | //初始化数据 |
| | | initData(); |
| | | //初始化界面 |
| | | initView(); |
| | | //初始化监听器 |
| | | initEvent(); |
| | | //初始化数据 |
| | | initData(); |
| | | } |
| | | |
| | | private void initData() { |
| | | mList = new ArrayList<>(); |
| | | mList.clear(); |
| | | for (int i = 0; i < 5; i++) { |
| | | MessageBean messageBean = new MessageBean(); |
| | | messageBean.setContent("来了一条告警信息" + i); |
| | | messageBean.setHomeName(UserConfigManage.getInstance().getHomeName()); |
| | | messageBean.setHomeName(i + ""); |
| | | messageBean.setTime("2023-12-06-15"); |
| | | messageBean.setRead(false); |
| | | if (i == 2 || i == 4) { |
| | | messageBean.setRead(true); |
| | | mList.add(messageBean); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void initEvent() { |
| | | if (messageAllAdapter != null) { |
| | | messageAllAdapter.setNoOnclickListener(new MessageAdapter.OnclickListener() { |
| | | @Override |
| | | public void onClick(int position, MessageBean item) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void initView() { |
| | | viewBinding.messageAllRecyclerview.setLayoutManager(new LinearLayoutManager(_mActivity)); |
| | | messageAllAdapter = new MessageAdapter(this.mList, _mActivity); |
| | | viewBinding.messageAllRecyclerview.setAdapter(messageAllAdapter); |
| | | } |
| | | |
| | | private void updateListData() { |
| | | if (this.messageAllAdapter != null) { |
| | | this.messageAllAdapter.notifyDataSetChanged(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onEventMessage(BaseEventBus eventBus) { |
| | | super.onEventMessage(eventBus); |
| | | //接收外部点击事件 |
| | | if (eventBus.getTopic().equals(ConstantManage.message_function_tab_switch)) { |
| | | if (eventBus.getType().equals(HdlCommonLogic.MessageFunctionTabSwitch.all.toString())) { |
| | | updateListData(); |
| | | HdlLogLogic.print("正在点击【全部】"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void initEvent() { |
| | | messageAdapter.setNoOnclickListener(new MessageAdapter.OnclickListener() { |
| | | @Override |
| | | public void onClick(int position, MessageBean item) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void initView() { |
| | | LinearLayoutManager linearLayout = new LinearLayoutManager(_mActivity); |
| | | messageAdapter = new MessageAdapter(this.mList, _mActivity); |
| | | viewBinding.messageAllRecyclerview.setLayoutManager(linearLayout); |
| | | viewBinding.messageAllRecyclerview.setAdapter(messageAdapter); |
| | | } |
| | | } |