Malinskiy / SuperRecyclerView

Pumped up RecyclerView
2.63k stars 469 forks source link

setupMoreListener Add a judgment #99

Open LuoGuoXin opened 8 years ago

LuoGuoXin commented 8 years ago

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.