Skip to content

Commit

Permalink
修复list页面设置第一页为0刷新后下一页为2的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yaozs committed Apr 26, 2018
1 parent 3669d95 commit e22644c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
* 17.08.02 优化默认tooblar颜色设置,自动适配项目颜色
* 17.08.07 优化list界面自动化处理,一句代码搞定各种加载状态 autoListLoad 方法诞生
* 18.04.19 添加YzsBaseActivity框架方法详解,整理代码,梳理逻辑
* 18.04.26 修复list页面设置第一页为0刷新后下一页为2的bug


### 本项目使用开源项目
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public abstract class YzsBaseMvpListFragment<T extends BasePresenter, E extends

private int mPage = 1;
private int mPageSize = 10;
private int startPageNum = 1;

public void setmPageSize(int mPageSize) {
this.mPageSize = mPageSize;
Expand Down Expand Up @@ -239,7 +240,7 @@ protected void convert(BaseViewHolder baseViewHolder, D t) {
public void okRefresh() {
judgeViewIsNull();
if (mAdapter != null) {
mPage = 2;
mPage = startPageNum+1;
mRefreshLayout.finishRefresh();
mRefreshLayout.setLoadmoreFinished(false);//恢复上拉状态
Logger.d("refresh_complete");
Expand All @@ -248,7 +249,7 @@ public void okRefresh() {

public void autoListLoad(@Nullable List<D> tList, String empty_str, @DrawableRes int Empty_res) {
tList = tList == null ? new ArrayList<D>() : tList;
if (getPage() == 1) {
if (getPage() == startPageNum) {
okRefresh();
mAdapter.setNewData(tList);
if (tList.size() == 0) {
Expand All @@ -273,7 +274,7 @@ public void autoListLoad(@Nullable List<D> tList, String empty_str, @DrawableRes
* @param isFail
*/
public void autoListLoad(@Nullable List<D> tList, String empty_str, @DrawableRes int empty_res, boolean isFail) {
if (isFail && getPage() != 1) {
if (isFail && getPage() != startPageNum) {
failLoadMore();
} else {
autoListLoad(tList, empty_str, empty_res);
Expand Down Expand Up @@ -312,6 +313,7 @@ public int getPage() {

public void setPage(int page) {
mPage = page;
startPageNum = page;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public abstract class YzsBaseMvpListTypeFragment<T extends BasePresenter, E exte

private int mPage = 1;
private int mPageSize = 10;
private int startPageNum = 1;

public void setmPageSize(int mPageSize) {
this.mPageSize = mPageSize;
Expand Down Expand Up @@ -243,7 +244,7 @@ public void addItemType(int type, @LayoutRes int layoutResId) {
*/
public void autoListLoad(@Nullable List<D> tList, String empty_str, @DrawableRes int empty_res) {
tList = tList == null ? new ArrayList<D>() : tList;
if (getPage() == 1) {
if (getPage() == startPageNum) {
okRefresh();
mAdapter.setNewData(tList);
if (tList.size() == 0) {
Expand All @@ -268,7 +269,7 @@ public void autoListLoad(@Nullable List<D> tList, String empty_str, @DrawableRes
* @param isFail
*/
public void autoListLoad(@Nullable List<D> tList, String empty_str, @DrawableRes int empty_res, boolean isFail) {
if (isFail && getPage() != 1) {
if (isFail && getPage() != startPageNum) {
failLoadMore();
} else {
autoListLoad(tList, empty_str, empty_res);
Expand All @@ -285,7 +286,7 @@ public void autoListLoad(@Nullable List<D> tList, String empty_str, @DrawableRes
public void okRefresh() {
judgeViewIsNull();
if (mAdapter != null) {
mPage = 2;
mPage = startPageNum + 1;
mRefreshLayout.finishRefresh();
mRefreshLayout.setLoadmoreFinished(false);//恢复上拉状态
Logger.d("refresh_complete");
Expand Down Expand Up @@ -321,6 +322,7 @@ public int getPage() {

public void setPage(int page) {
mPage = page;
startPageNum = page;
}

/**
Expand Down

0 comments on commit e22644c

Please sign in to comment.