I know why my Extended ScrollViews onScrollChanged is being called multiple times when end is reached with onScrollEnd (Its because I "reach end" multiple times with scrolling and thus calling onScrollEnd multiple times) and because of that its Loading multiple entries from Database while I want it to Load them once when first end is reached.
in my ExtendedScrollView class i have
protected void onScrollChanged(int x, int y, int oldx, int oldy) {
View view = (View) getChildAt(getChildCount() - 1);
int diff = (view.getBottom()-(getHeight()+getScrollY()+view.getTop()));
if (diff == 0) {
if (scrollViewListener != null) {
scrollViewListener.onScrollEnded(this, x, y, oldx, oldy);
}
}
super.onScrollChanged(x, y, oldx, oldy);
}
with
public interface ScrollViewListener {
void onScrollEnded(ExtendedScrollView scrollView, int x, int y, int oldx, int oldy);
}
In my Activity I have
@Override
public void onScrollEnded(ExtendedScrollView scrollView, int x, int y, int oldx, int oldy) {
//Called multiple times because of scroll but needed only once
//read 6 Strings (for example) from Database and refresh Tableview with that data (working so I think there is no need for the code)
}
So is there a way to stop getting multiple "ends" (caused by scrolling). Only to get the OnScrollEnded Once and load only 6 Strings from DB (Because of scrolling its called multiple times), then on the next 12 Scroll read next 6 and so on...
Any help is appreciated.