@@ -0,0 +1,2021 @@
+package com.mikepenz.fastadapter_extensions.scroll;%0A%0Aimport android.support.v7.widget.LinearLayoutManager;%0Aimport android.support.v7.widget.RecyclerView;%0A%0Apublic abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener %7B%0A%0A    private int mPreviousTotal = 0;%0A    private boolean mLoading = true;%0A    private int mVisibleThreshold = 30;%0A    private int mFirstVisibleItem, mVisibleItemCount, mTotalItemCount;%0A%0A    private int mCurrentPage = 1;%0A%0A    private LinearLayoutManager mLinearLayoutManager;%0A%0A    public EndlessRecyclerOnScrollListener(LinearLayoutManager linearLayoutManager) %7B%0A        this.mLinearLayoutManager = linearLayoutManager;%0A    %7D%0A%0A    public EndlessRecyclerOnScrollListener(LinearLayoutManager linearLayoutManager, int visibleThreshold) %7B%0A        this.mLinearLayoutManager = linearLayoutManager;%0A        this.mVisibleThreshold = visibleThreshold;%0A    %7D%0A%0A    @Override%0A    public void onScrolled(RecyclerView recyclerView, int dx, int dy) %7B%0A        super.onScrolled(recyclerView, dx, dy);%0A%0A        mVisibleItemCount = recyclerView.getChildCount();%0A        mTotalItemCount = mLinearLayoutManager.getItemCount();%0A        mFirstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition();%0A%0A        if (mLoading) %7B%0A            if (mTotalItemCount %3E mPreviousTotal) %7B%0A                mLoading = false;%0A                mPreviousTotal = mTotalItemCount;%0A            %7D%0A        %7D%0A        if (!mLoading && (mTotalItemCount - mVisibleItemCount)%0A                %3C= (mFirstVisibleItem + mVisibleThreshold)) %7B%0A%0A            mCurrentPage++;%0A%0A            onLoadMore(mCurrentPage);%0A%0A            mLoading = true;%0A        %7D%0A    %7D%0A%0A    public int getTotalItemCount() %7B%0A        return mTotalItemCount;%0A    %7D%0A%0A    public int getFirstVisibleItem() %7B%0A        return mFirstVisibleItem;%0A    %7D%0A%0A    public int getVisibleItemCount() %7B%0A        return mVisibleItemCount;%0A    %7D%0A%0A    public int getCurrentPage() %7B%0A        return mCurrentPage;%0A    %7D%0A%0A    public abstract void onLoadMore(int currentPage);%0A%7D

add EndlessRecyclerOnScrollListener