Back to project page InfiniteScrollListView.
The source code is released under:
MIT License
If you think the Android project InfiniteScrollListView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.sandersdenardi.infinitescrolllistview.app.lib; // w w w. j av a 2 s.c om import android.widget.AbsListView; public class InfiniteScrollOnScrollListener implements AbsListView.OnScrollListener { private static final int SCROLL_OFFSET = 2; private IInfiniteScrollListener listener; public InfiniteScrollOnScrollListener(IInfiniteScrollListener listener) { this.listener = listener; } @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (totalItemCount - (firstVisibleItem + 1 + visibleItemCount) < SCROLL_OFFSET && visibleItemCount < totalItemCount) { listener.endIsNear(); } // Item visibility code listener.onScrollCalled(firstVisibleItem, visibleItemCount, totalItemCount); } public void checkForFetchMore(final AbsListView listView) { Runnable fetchMore = new Runnable() { @Override public void run() { int last = listView.getLastVisiblePosition(); if (listView.getChildAt(last) != null) { int bottom = listView.getChildAt(last).getBottom(); int count = listView.getCount(); int height = listView.getHeight(); if (last == count - 1 && bottom <= height) { listener.endIsNear(); } } } }; listView.post(fetchMore); } }