@Override | @Override | ||||
public void onLoadMore(@NonNull @NotNull RefreshLayout refreshLayout) { | public void onLoadMore(@NonNull @NotNull RefreshLayout refreshLayout) { | ||||
if (!hasMore) { | |||||
binding.rlStatusRefresh.finishLoadMore(); | |||||
return; | |||||
} | |||||
postDelayed(() -> { | postDelayed(() -> { | ||||
if (!hasMore) { | |||||
binding.rlStatusRefresh.finishLoadMore(); | |||||
return; | |||||
} | |||||
page = page + 1; | page = page + 1; | ||||
loadData(); | loadData(); | ||||
binding.rlStatusRefresh.finishLoadMore(); | binding.rlStatusRefresh.finishLoadMore(); |
import com.huntersun.vkyes.etcopencard.project.api.bean.IFCode; | import com.huntersun.vkyes.etcopencard.project.api.bean.IFCode; | ||||
import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | ||||
import com.huntersun.vkyes.etcopencard.project.api.bean.SendTheVerificationCodeBean; | import com.huntersun.vkyes.etcopencard.project.api.bean.SendTheVerificationCodeBean; | ||||
import com.huntersun.vkyes.etcopencard.project.utils.FunHelper; | |||||
import com.huntersun.vkyes.etcopencard.src.action.StatusAction; | import com.huntersun.vkyes.etcopencard.src.action.StatusAction; | ||||
import com.huntersun.vkyes.etcopencard.src.aop.SingleClick; | import com.huntersun.vkyes.etcopencard.src.aop.SingleClick; | ||||
import com.huntersun.vkyes.etcopencard.src.app.AppActivity; | import com.huntersun.vkyes.etcopencard.src.app.AppActivity; | ||||
public class ListDeliveryActivity extends AppActivity implements OnRefreshLoadMoreListener, StatusAction { | public class ListDeliveryActivity extends AppActivity implements OnRefreshLoadMoreListener, StatusAction { | ||||
private ActivityListDeliveryBinding binding; | private ActivityListDeliveryBinding binding; | ||||
private int Page = 1; | private int Page = 1; | ||||
private boolean hasMore; | |||||
@Override | @Override | ||||
protected View getLayoutView() { | protected View getLayoutView() { | ||||
@Override | @Override | ||||
protected void initData() { | protected void initData() { | ||||
if (Page == 1) hasMore = true; | |||||
SendTheVerificationCodeBean bizContent = new SendTheVerificationCodeBean(); | SendTheVerificationCodeBean bizContent = new SendTheVerificationCodeBean(); | ||||
bizContent.setPageNo(Page); | bizContent.setPageNo(Page); | ||||
RequestParameters parameters = | RequestParameters parameters = | ||||
.enqueue(new Converter<Result>(this, "列表数据加载中...") { | .enqueue(new Converter<Result>(this, "列表数据加载中...") { | ||||
@Override | @Override | ||||
protected void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | protected void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | ||||
showComplete(); | |||||
if (bizContent.getData() == null) { | |||||
showEmpty(); | |||||
return; | |||||
} | |||||
int pageSize = 10; // 每页的数据条数 | |||||
int totalSize = Integer.parseInt(bizContent.getTotalCount()); // 获取总的数据条数 | int totalSize = Integer.parseInt(bizContent.getTotalCount()); // 获取总的数据条数 | ||||
int pageCount = totalSize / pageSize; // 计算总页数 | |||||
List<ResultBean.BizContent> list = bizContent.getData(); | |||||
if (Page == 1) { | if (Page == 1) { | ||||
adapter.replaceData(list); | |||||
adapter.replaceData(bizContent.getData()); | |||||
} else { | } else { | ||||
if (totalSize % pageSize == 0) { | |||||
adapter.addData(list); | |||||
} else { | |||||
toast("没有更多数据了!"); | |||||
if (!FunHelper.isEmpty(bizContent.getData())){ | |||||
adapter.addData(bizContent.getData()); | |||||
} | } | ||||
} | } | ||||
if (list.size() == 0 && Page == 1) { | |||||
if (FunHelper.isEmpty(bizContent.getData()) && Page == 1) { | |||||
showEmpty(); | showEmpty(); | ||||
} else { | } else { | ||||
showComplete(); | showComplete(); | ||||
} | } | ||||
if (adapter.getData().size() >= totalSize){ | |||||
hasMore = false; | |||||
}else{ | |||||
hasMore = true; | |||||
} | |||||
} | } | ||||
@Override | @Override | ||||
@Override | @Override | ||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) { | public void onLoadMore(@NonNull RefreshLayout refreshLayout) { | ||||
if (!hasMore) { | |||||
binding.rlStatusRefresh.finishLoadMore(); | |||||
return; | |||||
} | |||||
postDelayed(() -> { | postDelayed(() -> { | ||||
Page++; | Page++; | ||||
initData(); | initData(); |
import com.huntersun.vkyes.etcopencard.project.ui.activity.MainActivity; | import com.huntersun.vkyes.etcopencard.project.ui.activity.MainActivity; | ||||
import com.huntersun.vkyes.etcopencard.project.ui.activity.order.OrderUtils; | import com.huntersun.vkyes.etcopencard.project.ui.activity.order.OrderUtils; | ||||
import com.huntersun.vkyes.etcopencard.project.utils.Constants; | import com.huntersun.vkyes.etcopencard.project.utils.Constants; | ||||
import com.huntersun.vkyes.etcopencard.project.utils.FunHelper; | |||||
import com.huntersun.vkyes.etcopencard.src.action.StatusAction; | import com.huntersun.vkyes.etcopencard.src.action.StatusAction; | ||||
import com.huntersun.vkyes.etcopencard.src.aop.SingleClick; | import com.huntersun.vkyes.etcopencard.src.aop.SingleClick; | ||||
import com.huntersun.vkyes.etcopencard.src.app.AppFragment; | import com.huntersun.vkyes.etcopencard.src.app.AppFragment; | ||||
private int page = 1; | private int page = 1; | ||||
private int orderStep = 0; | private int orderStep = 0; | ||||
private String licensePlate; | private String licensePlate; | ||||
private boolean hasMore; | |||||
public static AppFragment<MainActivity> newInstance(int start) { | public static AppFragment<MainActivity> newInstance(int start) { | ||||
return new FragmentSonOne(start); | return new FragmentSonOne(start); | ||||
} | } | ||||
public void LoadData() { | public void LoadData() { | ||||
if (page == 1 ) hasMore = true; | |||||
List<String> list = null; | List<String> list = null; | ||||
Parameters parameters = new Parameters(); | Parameters parameters = new Parameters(); | ||||
//0 - 全部 1 - 申办中 2 - 待发货 3 - 待激活 4 - 已完成 | //0 - 全部 1 - 申办中 2 - 待发货 3 - 待激活 4 - 已完成 | ||||
@SuppressLint("NotifyDataSetChanged") | @SuppressLint("NotifyDataSetChanged") | ||||
@Override | @Override | ||||
protected void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent1) { | protected void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent1) { | ||||
if (bizContent1.getData() == null) { | |||||
postDelayed(FragmentSonOne.this::showEmpty, 300); | |||||
return; | |||||
} | |||||
int pageSize = 10; // 每页的数据条数 | |||||
int totalSize = Integer.parseInt(bizContent1.getTotalCount()); // 获取总的数据条数 | int totalSize = Integer.parseInt(bizContent1.getTotalCount()); // 获取总的数据条数 | ||||
int pageCount = totalSize / pageSize; // 计算总页数 | |||||
List<ResultBean.BizContent> list = bizContent1.getData(); | |||||
if (page == 1) { | if (page == 1) { | ||||
adapter.replaceData(list); | |||||
adapter.replaceData(bizContent1.getData()); | |||||
} else { | } else { | ||||
if (totalSize % pageSize == 0) { | |||||
adapter.addData(list); | |||||
} else { | |||||
toast("没有更多数据了!"); | |||||
if (!FunHelper.isEmpty(bizContent1.getData())){ | |||||
adapter.addData(bizContent1.getData()); | |||||
} | } | ||||
} | } | ||||
if (list.size() == 0 && page == 1) { | |||||
if (FunHelper.isEmpty(bizContent1.getData()) && page == 1) { | |||||
showEmpty(); | showEmpty(); | ||||
} else { | } else { | ||||
showComplete(); | showComplete(); | ||||
} | } | ||||
if (adapter.getData().size() >= totalSize){ | |||||
hasMore = false; | |||||
}else{ | |||||
hasMore = true; | |||||
} | |||||
} | } | ||||
@Override | @Override | ||||
@Override | @Override | ||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) { | public void onLoadMore(@NonNull RefreshLayout refreshLayout) { | ||||
if (!hasMore) { | |||||
binding.rlStatusRefresh.finishLoadMore(); | |||||
return; | |||||
} | |||||
postDelayed(() -> { | postDelayed(() -> { | ||||
page = page + 1; | page = page + 1; | ||||
LoadData(); | LoadData(); |