| | |
| | | import android.annotation.SuppressLint; |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | |
| | | 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.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.bean.MessageBean; |
| | | import com.hdl.photovoltaic.utils.GlideUtils; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | private final List<MessageBean> mList = new ArrayList<>(); |
| | | private int currentPage = 0; // 当前页码 |
| | | private int total = 0; // 最后页码 |
| | | private int currentTotal = 0; // 总页码 |
| | | |
| | | |
| | | private boolean isLoadingMore = false; // 标记正在加载更多数据 |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | //初始化数据 |
| | | // initData(); |
| | | //初始化界面 |
| | | initView(); |
| | | //初始化监听器 |
| | | initEvent(); |
| | | //进来读取一次数据(为了更新currentPage,currentTotal这个值) |
| | | loadNextPageNascentMessageList(1, true); |
| | | } |
| | | |
| | | private void initData() { |
| | | mList.clear(); |
| | | mList.addAll(HdlMessageLogic.getInstance().getNascentMessageMemoryList()); |
| | | } |
| | | |
| | | private void initEvent() { |
| | | //设置下拉箭头颜色 |
| | |
| | | @Override |
| | | public void onRefresh() { |
| | | viewBinding.messageNascentSrl.setRefreshing(false); |
| | | // mList.clear();//表示强制重新请求消息列表 |
| | | // updateListData();//清空之前缓存,因为遇到一个问题猛拉的时候报错; |
| | | // getNascentMessageList(false); |
| | | mList.clear();//表示强制重新请求第一页消息列表 |
| | | HdlMessageLogic.getInstance().clearListMessage();//表示强制清空所有缓存信息 |
| | | loadNextPageNascentMessageList(1, true); |
| | | } |
| | | }); |
| | | messageNascentAdapter.setNoOnclickListener(new MessageAdapter.OnclickListener() { |
| | |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //更新缓存数据 |
| | | initData(); |
| | | //更新本地缓存数据 |
| | | updatelocalityCacheData(); |
| | | //刷新列表 |
| | | if (messageNascentAdapter != null) { |
| | | messageNascentAdapter.setList(mList); |
| | |
| | | //接收外部点击事件 |
| | | if (eventBus.getTopic().equals(ConstantManage.message_function_tab_switch)) { |
| | | if (eventBus.getType().equals(MessageFunctionTabSwitch.nascent.toString())) { |
| | | initData(); |
| | | loadNextPageNascentMessageList(1, true); |
| | | // getUnreadCount(); |
| | | // 取消粘性事件 |
| | | EventBus.getDefault().removeStickyEvent(eventBus); |
| | | |
| | |
| | | } else if (eventBus.getTopic().equals(ConstantManage.message_function_push_post)) { |
| | | if (eventBus.getType().equals(MessageStateType.untreated)) { |
| | | //消息详情回调 |
| | | initData(); |
| | | updatelocalityCacheData(); |
| | | updateListData(); |
| | | // getUnreadCount(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新本地缓存数据 |
| | | */ |
| | | private void updatelocalityCacheData() { |
| | | mList.clear(); |
| | | mList.addAll(HdlMessageLogic.getInstance().getNascentMessageMemoryList()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param isShowLoading 是否启动加载框 true启动 |
| | | */ |
| | | private void loadNextPageNascentMessageList(int pageNo, boolean isShowLoading) { |
| | | if (pageNo == 1 && mList.size() > 0) { |
| | | //没有缓存数据,才可以读取第一页 |
| | | return; |
| | | } |
| | | if (currentPage > total) { |
| | | //第一页读取数据强制读 |
| | | if (pageNo > 1 && currentPage > currentTotal) { |
| | | --currentPage; |
| | | //当前页不能大于总页数 |
| | | return; |
| | | } |
| | |
| | | @Override |
| | | public void onSuccess(HdlMessageLogic.MessageListClass messageListClass) { |
| | | if (messageListClass != null) { |
| | | total = (int) messageListClass.getTotalPage(); |
| | | currentTotal = (int) messageListClass.getTotalPage(); |
| | | currentPage = (int) messageListClass.getPageNo(); |
| | | updateListData(); |
| | | } |
| | |
| | | * 读取消息【未读数量】 |
| | | */ |
| | | private void getUnreadCount() { |
| | | HdlMessageLogic.getInstance().getMessageUntreatedCount(new CloudCallBeak<String>() { |
| | | HdlMessageLogic.getInstance().getMessageUntreatedCount("",new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String data) { |
| | | |