I have a ListView in which, as the question suggests, I am loading images with a delay. The problem is that this method is overriding my custom onScrollListener. I tried using:
aq.id(listview).scrolled(new customScrollListener());
aq.id(listview).adapter(myAdapter);
These two lines are in the calling activity class, and I do this after I have loaded all data in the list. Even after this the scrollListener doesn't seem to be working. Where am I going wrong? Any ideas?
UPDATE - CustomScrollListener:
private class CustomScrollListener implements OnScrollListener {
private Context context;
private int visibleThreshold = 0;
private int currentPage = 0;
private int previousTotal = 0;
private boolean loading = true;
CustomScrollListener(Context context) {
this.context = context;
}
CustomScrollListener(int visibleThreshold) {
this.visibleThreshold = visibleThreshold;
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (loading) {
if (totalItemCount > previousTotal) {
loading = false;
previousTotal = totalItemCount;
currentPage++;
}
}
if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold) && totalItemCount>10) {
// do something
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
}