Skip to content

Commit

Permalink
Merge pull request CymChad#185 from shichaohui/master
Browse files Browse the repository at this point in the history
  • Loading branch information
CymChad authored Jul 26, 2016
2 parents f60eb9f + 4ec52b4 commit 06b8f8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -80,18 +84,17 @@ public void run() {
}
}


});
}


@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mQuickAdapter.setNewData(DataServer.getSampleData(PAGE_SIZE));
mQuickAdapter.openLoadMore(PAGE_SIZE, true);
mQuickAdapter.removeAllFooterView();
mCurrentCounter = PAGE_SIZE;
mSwipeRefreshLayout.setRefreshing(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public void setNewData(List<T> data) {
this.mData = data;
if (mRequestLoadMoreListener != null) {
mNextLoadEnable = true;
mFooterLayout = null;
// mFooterLayout = null;
}
mLastPosition = -1;
notifyDataSetChanged();
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 06b8f8d

Please sign in to comment.