Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

setupMoreListener Add a judgment #99

Open
LuoGuoXin opened this issue Jun 30, 2016 · 0 comments
Open

setupMoreListener Add a judgment #99

LuoGuoXin opened this issue Jun 30, 2016 · 0 comments

Comments

@LuoGuoXin
Copy link

private void processOnMore() {
RecyclerView.LayoutManager layoutManager = mRecycler.getLayoutManager();
int lastVisibleItemPosition = getLastVisibleItemPosition(layoutManager);
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();

    if (((totalItemCount - lastVisibleItemPosition) <= ITEM_LEFT_TO_LOAD_MORE ||
         (totalItemCount - lastVisibleItemPosition) == 0 && totalItemCount > visibleItemCount)
        && !isLoadingMore) {

        isLoadingMore = true;
        if (mOnMoreListener != null) {
            mMoreProgress.setVisibility(View.VISIBLE);
            mOnMoreListener.onMoreAsked(mRecycler.getAdapter().getItemCount(), ITEM_LEFT_TO_LOAD_MORE, lastVisibleItemPosition);
        }
    }
}

When the list.size()==0,Not need to call setupMoreListener.

When I call setRefreshListener,
@OverRide
public void onRefresh() {
pageNumber = 1;
list.clear();
adapter.notifyDataSetChanged();
getFriendHttp();
}
Because I call "list.clear();adapter.notifyDataSetChanged();",So the list.size()==0,and will call setupMoreListener.

Normally,when I call refreshListener,it need not to call setupmorelistener.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant