| | |
| | | import android.os.Bundle; |
| | | |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseFragment; |
| | | import com.hdl.photovoltaic.config.ConstantManage; |
| | | import com.hdl.photovoltaic.databinding.FragmentNascentMessageBinding; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlMessageLogic; |
| | | import com.hdl.photovoltaic.ui.adapter.MessageAdapter; |
| | | import com.hdl.photovoltaic.ui.bean.MessageBean; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | |
| | | |
| | | private MessageAdapter messageNascentAdapter; |
| | | |
| | | private List<MessageBean> mList; |
| | | private List<MessageBean> mList = new ArrayList<>(); |
| | | |
| | | @Override |
| | | public Object getContentView() { |
| | |
| | | } |
| | | |
| | | private void initData() { |
| | | mList = new ArrayList<>(); |
| | | for (int i = 0; i < 3; i++) { |
| | | MessageBean messageBean = new MessageBean(); |
| | | messageBean.setContent("来了一条告警信息" + i); |
| | | messageBean.setHomeName(i + ""); |
| | | messageBean.setTime("2023-12-06-15"); |
| | | messageBean.setRead(false); |
| | | mList.add(messageBean); |
| | | } |
| | | // mList = new ArrayList<>(); |
| | | // for (int i = 0; i < 3; i++) { |
| | | // MessageBean messageBean = new MessageBean(); |
| | | // messageBean.setTitle("来了一条告警信息" + i); |
| | | // messageBean.setHomeName(i + ""); |
| | | // messageBean.setCreateTime((long) 1234567777); |
| | | // messageBean.setRead(false); |
| | | // mList.add(messageBean); |
| | | // } |
| | | } |
| | | |
| | | private void initEvent() { |
| | | //设置下拉箭头颜色 |
| | | viewBinding.messageNascentSrl.setColorSchemeResources(R.color.text_FF245EC3); |
| | | viewBinding.messageNascentSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | mList.clear();//表示强制重新请求消息列表 |
| | | getNascentMessageList(false); |
| | | } |
| | | }); |
| | | messageNascentAdapter.setNoOnclickListener(new MessageAdapter.OnclickListener() { |
| | | @Override |
| | | public void onClick(int position, MessageBean item) { |
| | |
| | | viewBinding.messageNascentRecyclerview.setAdapter(messageNascentAdapter); |
| | | } |
| | | |
| | | /** |
| | | * 刷新列表数据 |
| | | */ |
| | | private void updateListData() { |
| | | if (this.messageNascentAdapter != null) { |
| | | this.messageNascentAdapter.setList(mList); |
| | | this.messageNascentAdapter.notifyDataSetChanged(); |
| | | } |
| | | } |
| | |
| | | //接收外部点击事件 |
| | | if (eventBus.getTopic().equals(ConstantManage.message_function_tab_switch)) { |
| | | if (eventBus.getType().equals(HdlCommonLogic.MessageFunctionTabSwitch.nascent.toString())) { |
| | | HdlLogLogic.print("正在点击【进行中】"); |
| | | getNascentMessageList(true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取发生中的消息列表 |
| | | * |
| | | * @param isShowLoading 是否启动 true启动 |
| | | */ |
| | | private void getNascentMessageList(boolean isShowLoading) { |
| | | if (mList.size() == 0) { |
| | | if (isShowLoading) { |
| | | showLoading(); |
| | | } |
| | | HdlMessageLogic.getInstance().getMessageList(HdlMessageLogic.MessageStatus.untreated, new CloudCallBeak<List<MessageBean>>() { |
| | | @Override |
| | | public void onSuccess(List<MessageBean> list) { |
| | | if (isShowLoading) { |
| | | hideLoading(); |
| | | } |
| | | if (!isShowLoading) { |
| | | viewBinding.messageNascentSrl.setRefreshing(false); |
| | | } |
| | | |
| | | if (list != null && list.size() != 0) { |
| | | mList.addAll(list); |
| | | updateListData(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | if (isShowLoading) { |
| | | hideLoading(); |
| | | } |
| | | if (!isShowLoading) { |
| | | viewBinding.messageNascentSrl.setRefreshing(false); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |