我在recyclerView
获取了分页概念的默认卡片,
因为片段中的代码如下:
private void onResponse(String response) {
NewEnquiryPagination newEnquiries = new Gson().fromJson(response, new TypeToken<NewEnquiryPagination>() {
}.getType());
Log.i("@sandy,", "newEnquiriesFirstPage: " + newEnquiries);
if (listOfEnquiries !=null) {
adapter.addAll(newEnquiries.getContent());
if (currentPage <= TOTAL_PAGES) adapter.addLoadingFooter();
else isLastPage = true;
}
}
private void onResponseNextPage(String response) {
adapter.removeLoadingFooter();
isLoading = false;
NewEnquiryPagination newEnquiries = new Gson().fromJson(response, new TypeToken<NewEnquiryPagination>() {
}.getType());
if (listOfEnquiries != null ) {
adapter.addAll(newEnquiries.getContent());
if (currentPage != TOTAL_PAGES) adapter.addLoadingFooter();
else isLastPage = true;
}
}
我将内容列表显示为空,但默认情况下我已获取卡片设置,并且SwipeRefresh
卡片正在增加一张......问题出在loadFirstPage();
方法,如果列表为空,我只想将snackbar
显示为空,而SwipeRefresh
我只想刷新列表。
请帮帮我
答案 0 :(得分:1)
只需将此If条件设置为检查列表的空值和大小,
if (newEnquiries.getContent() != null && newEnquiries.getContent().size() > 0) {
Log.i("@sss","OnRes");
adapter.addAll(newEnquiries.getContent());
if (currentPage <= TOTAL_PAGES) adapter.addLoadingFooter();
else isLastPage = true;
} else {
//Your else condition
}
希望如此有帮助