|
@@ -24,6 +24,7 @@ import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
|
|
|
|
import com.cooleshow.base.utils.GsonUtils;
|
|
|
import com.cooleshow.base.utils.JumpUtils;
|
|
|
+import com.cooleshow.base.utils.LOG;
|
|
|
import com.cooleshow.base.utils.SizeUtils;
|
|
|
import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
|
|
|
import com.cooleshow.student.R;
|
|
@@ -33,6 +34,7 @@ import com.cooleshow.student.bean.SystemMessageBean;
|
|
|
import com.cooleshow.student.contract.MessageBoxContract;
|
|
|
import com.cooleshow.student.databinding.ActivityMessageBoxBinding;
|
|
|
import com.cooleshow.student.presenter.message.MessageBoxPresenter;
|
|
|
+import com.scwang.smart.refresh.footer.ClassicsFooter;
|
|
|
import com.scwang.smart.refresh.layout.api.RefreshLayout;
|
|
|
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
|
|
|
|
|
@@ -50,6 +52,8 @@ import java.util.List;
|
|
|
public class MessageBoxActivity extends BaseMVPActivity<ActivityMessageBoxBinding, MessageBoxPresenter> implements MessageBoxContract.MessageBoxView, View.OnClickListener {
|
|
|
//SYSTEM:系统消息 COURSE:课程信息 NOTICE:公告
|
|
|
private String group = "";
|
|
|
+ private MessageBoxAdapter messageBoxAdapter;
|
|
|
+ private boolean hasNext = true;
|
|
|
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
@@ -98,11 +102,10 @@ public class MessageBoxActivity extends BaseMVPActivity<ActivityMessageBoxBindin
|
|
|
QMUIStatusBarHelper.setStatusBarLightMode(this);
|
|
|
}
|
|
|
|
|
|
- private MessageBoxAdapter messageBoxAdapter;
|
|
|
-
|
|
|
@Override
|
|
|
protected void initView() {
|
|
|
initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "消息盒子");
|
|
|
+ viewBinding.refreshLayout.setRefreshFooter(new ClassicsFooter(this));
|
|
|
viewBinding.clAll.setOnClickListener(this);
|
|
|
viewBinding.clCourse.setOnClickListener(this);
|
|
|
viewBinding.clSystem.setOnClickListener(this);
|
|
@@ -173,15 +176,16 @@ public class MessageBoxActivity extends BaseMVPActivity<ActivityMessageBoxBindin
|
|
|
queryList(true);
|
|
|
}
|
|
|
});
|
|
|
- messageBoxAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
|
|
|
+
|
|
|
+ viewBinding.refreshLayout.setOnLoadMoreListener(new com.scwang.smart.refresh.layout.listener.OnLoadMoreListener() {
|
|
|
@Override
|
|
|
- public void onLoadMore() {
|
|
|
+ public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
|
|
//上拉加载
|
|
|
if (hasNext) {
|
|
|
currentPage++;
|
|
|
queryList(false);
|
|
|
} else {
|
|
|
- messageBoxAdapter.getLoadMoreModule().loadMoreEnd();
|
|
|
+ viewBinding.refreshLayout.finishLoadMoreWithNoMoreData();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -190,31 +194,37 @@ public class MessageBoxActivity extends BaseMVPActivity<ActivityMessageBoxBindin
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void sysMessageListSuccess(int page, SystemMessageBean data) {
|
|
|
- if (data != null) {
|
|
|
+ public void sysMessageListSuccess(int page, SystemMessageBean dataList) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (dataList != null) {
|
|
|
if (page == 1) {
|
|
|
- messageBoxAdapter.getData().clear();
|
|
|
- messageBoxAdapter.notifyDataSetChanged();
|
|
|
+ //第一页
|
|
|
viewBinding.refreshLayout.finishRefresh();
|
|
|
- if (data.rows != null && data.rows.size() > 0) {
|
|
|
- checkHasNext(data.rows.size());
|
|
|
- messageBoxAdapter.setNewInstance(data.rows);
|
|
|
- } else {
|
|
|
+ if (messageBoxAdapter != null) {
|
|
|
+ messageBoxAdapter.getData().clear();
|
|
|
messageBoxAdapter.notifyDataSetChanged();
|
|
|
+ if (dataList.getRows() != null && dataList.getRows().size() > 0) {
|
|
|
+ checkHasNext(dataList.getRows().size());
|
|
|
+ messageBoxAdapter.setNewInstance(dataList.getRows());
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
- if (data.rows != null && data.rows.size() > 0) {
|
|
|
- messageBoxAdapter.addData(data.rows);
|
|
|
- messageBoxAdapter.getLoadMoreModule().loadMoreComplete();
|
|
|
- checkHasNext(data.rows.size());
|
|
|
- } else {
|
|
|
- messageBoxAdapter.getLoadMoreModule().loadMoreEnd();
|
|
|
+ //加载更多
|
|
|
+ if (messageBoxAdapter != null) {
|
|
|
+ if (dataList.getRows() != null && dataList.getRows().size() > 0) {
|
|
|
+ viewBinding.refreshLayout.finishLoadMore();
|
|
|
+ checkHasNext(dataList.getRows().size());
|
|
|
+ messageBoxAdapter.addData(dataList.getRows());
|
|
|
+ } else {
|
|
|
+ viewBinding.refreshLayout.finishLoadMoreWithNoMoreData();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private boolean hasNext = true;
|
|
|
|
|
|
/**
|
|
|
* 检查是否还有下一页
|
|
@@ -226,18 +236,24 @@ public class MessageBoxActivity extends BaseMVPActivity<ActivityMessageBoxBindin
|
|
|
}
|
|
|
|
|
|
private void queryList(boolean isLoading) {
|
|
|
+ if (currentPage == 1) {
|
|
|
+ viewBinding.refreshLayout.resetNoMoreData();
|
|
|
+ }
|
|
|
presenter.sysMessageList(isLoading, currentPage, group);
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void sysMessageListError(int page) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (page == 1) {
|
|
|
viewBinding.refreshLayout.finishRefresh();
|
|
|
} else {
|
|
|
if (messageBoxAdapter != null) {
|
|
|
currentPage--;
|
|
|
- messageBoxAdapter.getLoadMoreModule().loadMoreFail();
|
|
|
+ viewBinding.refreshLayout.finishLoadMore(false);
|
|
|
}
|
|
|
}
|
|
|
}
|