From 4ec52b491ec01b2856e45291f733fd63e6bfbc57 Mon Sep 17 00:00:00 2001 From: chaohui Date: Tue, 26 Jul 2016 15:27:10 +0800 Subject: [PATCH 1/3] fix bug. --- .../PullToRefreshUseActivity.java | 11 +++++++---- .../chad/library/adapter/base/BaseQuickAdapter.java | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/chad/baserecyclerviewadapterhelper/PullToRefreshUseActivity.java b/app/src/main/java/com/chad/baserecyclerviewadapterhelper/PullToRefreshUseActivity.java index b657aabf2..2992e6df4 100644 --- a/app/src/main/java/com/chad/baserecyclerviewadapterhelper/PullToRefreshUseActivity.java +++ b/app/src/main/java/com/chad/baserecyclerviewadapterhelper/PullToRefreshUseActivity.java @@ -24,6 +24,8 @@ public class PullToRefreshUseActivity extends Activity implements BaseQuickAdapt private QuickAdapter mQuickAdapter; private SwipeRefreshLayout mSwipeRefreshLayout; + private View notLoadingView; + private static final int TOTAL_COUNTER = 18; private static final int PAGE_SIZE = 6; @@ -67,8 +69,10 @@ public void onLoadMoreRequested() { public void run() { if (mCurrentCounter >= TOTAL_COUNTER) { mQuickAdapter.notifyDataChangedAfterLoadMore(false); - View view = getLayoutInflater().inflate(R.layout.not_loading, (ViewGroup) mRecyclerView.getParent(), false); - mQuickAdapter.addFooterView(view); + if (notLoadingView == null) { + notLoadingView = getLayoutInflater().inflate(R.layout.not_loading, (ViewGroup) mRecyclerView.getParent(), false); + } + mQuickAdapter.addFooterView(notLoadingView); } else { new Handler().postDelayed(new Runnable() { @Override @@ -80,11 +84,9 @@ public void run() { } } - }); } - @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @@ -92,6 +94,7 @@ public void onRefresh() { public void run() { mQuickAdapter.setNewData(DataServer.getSampleData(PAGE_SIZE)); mQuickAdapter.openLoadMore(PAGE_SIZE, true); + mQuickAdapter.removeAllFooterView(); mCurrentCounter = PAGE_SIZE; mSwipeRefreshLayout.setRefreshing(false); } diff --git a/library/src/main/java/com/chad/library/adapter/base/BaseQuickAdapter.java b/library/src/main/java/com/chad/library/adapter/base/BaseQuickAdapter.java index 53c928e72..30fb71405 100755 --- a/library/src/main/java/com/chad/library/adapter/base/BaseQuickAdapter.java +++ b/library/src/main/java/com/chad/library/adapter/base/BaseQuickAdapter.java @@ -336,7 +336,7 @@ public void setNewData(List data) { this.mData = data; if (mRequestLoadMoreListener != null) { mNextLoadEnable = true; - mFooterLayout = null; + // mFooterLayout = null; } mLastPosition = -1; notifyDataSetChanged(); @@ -520,6 +520,8 @@ else if ((!mFootAndEmptyEnable || !mHeadAndEmptyEnable) && position == 1 && mFoo return LOADING_VIEW; else return FOOTER_VIEW; + } else if (position > mData.size() + getHeaderLayoutCount()) { + return FOOTER_VIEW; } return getDefItemViewType(position - getHeaderLayoutCount()); } @@ -775,7 +777,7 @@ public void removeFooterView(View footer) { * remove all header view from mHeaderLayout and set null to mHeaderLayout */ public void removeAllHeaderView() { - if (mFooterLayout == null) return; + if (mHeaderLayout == null) return; mHeaderLayout.removeAllViews(); mHeaderLayout = null; From 6b29ba7f51852a72fdcb48206d38e4a1f0ebc06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AE=87=E6=98=8E?= Date: Tue, 26 Jul 2016 16:01:27 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 730f0e8ab..2b8db4426 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ allprojects { Add the dependency ```groovy dependencies { - compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:v1.9.3' + compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:v1.9.7' } ``` From ca4bc596eceb062c1588350743dffa15f1559827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AE=87=E6=98=8E?= Date: Tue, 26 Jul 2016 16:01:49 +0800 Subject: [PATCH 3/3] Update README-cn.md --- README-cn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-cn.md b/README-cn.md index 4bee86b6f..e2aba2c12 100644 --- a/README-cn.md +++ b/README-cn.md @@ -37,7 +37,7 @@ 然后在dependencies添加: ``` dependencies { - compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:v1.9.3' + compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:v1.9.7' } ```