| | |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlMessageLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.ui.adapter.MessageAdapter; |
| | | import com.hdl.photovoltaic.ui.bean.MessageBean; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | private void initData() { |
| | | // mList.clear(); |
| | | // for (int i = 0; i < 5; i++) { |
| | | // MessageBean messageBean = new MessageBean(); |
| | | //// messageBean.setContent("来了一条告警信息" + i); |
| | | // messageBean.setHomeName(i + ""); |
| | | //// messageBean.setTime("2023-12-06-15"); |
| | | // messageBean.setRead(false); |
| | | // mList.add(messageBean); |
| | | // } |
| | | mList.clear(); |
| | | mList.addAll(HdlMessageLogic.getInstance().getAllMessageList()); |
| | | } |
| | | |
| | | |
| | |
| | | @Override |
| | | public void onRefresh() { |
| | | mList.clear();//表示强制重新请求消息列表 |
| | | updateListData();//清空之前缓存,因为遇到一个问题猛拉的时候报错; |
| | | getAllMessageList(false); |
| | | HdlLogLogic.print("AllMessageFragment下拉刷新", false); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) |
| | | public void onEventMessage(BaseEventBus eventBus) { |
| | | super.onEventMessage(eventBus); |
| | | if (eventBus == null) { |
| | | return; |
| | | } |
| | | //接收外部点击事件 |
| | | if (eventBus.getTopic().equals(ConstantManage.message_function_tab_switch)) { |
| | | if (eventBus.getType().equals(MessageFunctionTabSwitch.all.toString())) { |
| | | initData(); |
| | | getAllMessageList(true); |
| | | HdlLogLogic.print("正在点击【全部】"); |
| | | // 取消粘性事件 |
| | | EventBus.getDefault().removeStickyEvent(eventBus); |
| | | } |
| | | } else if (eventBus.getTopic().equals(ConstantManage.message_function_push_post)) { |
| | | if (eventBus.getType().equals(MessageStateType.all)) { |
| | | //消息详情回调 |
| | | // initData(); |
| | | // updateListData(); |
| | | } |
| | | } |
| | | } |
| | |
| | | HdlMessageLogic.getInstance().getAllMessageList(new CloudCallBeak<List<MessageBean>>() { |
| | | @Override |
| | | public void onSuccess(List<MessageBean> list) { |
| | | if (isShowLoading) { |
| | | hideLoading(); |
| | | } |
| | | if (!isShowLoading) { |
| | | viewBinding.messageAllSrl.setRefreshing(false); |
| | | } |
| | | |
| | | if (list != null && list.size() != 0) { |
| | | mList.addAll(list); |
| | | updateListData(); |
| | | } |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (isShowLoading) { |
| | | hideLoading(); |
| | | } |
| | | if (!isShowLoading) { |
| | | viewBinding.messageAllSrl.setRefreshing(false); |
| | | } |
| | | |
| | | if (list != null && list.size() != 0) { |
| | | mList.addAll(list); |
| | | updateListData(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |