Skip to content

Instantly share code, notes, and snippets.

@marcel-ploch
Last active September 28, 2018 07:57
Show Gist options
  • Save marcel-ploch/6adf57e2b60c51f640d4ae7ec1ecd88e to your computer and use it in GitHub Desktop.
Save marcel-ploch/6adf57e2b60c51f640d4ae7ec1ecd88e to your computer and use it in GitHub Desktop.
Register Listener
public listViewLoaded(args: any): void {
this.listView = this.page.getViewById('playerListView');
if (isAndroid) {
this.listAdapter = this.listView.android.getAdapter();
}
if (isAndroid) {
const that: any = this;
let currentFirstVisibleItem: number;
let currentVisibleItemCount: number;
let currentTotalItemCount: number;
let currentScrollState: any;
const listener: any = new android.widget.AbsListView
.OnScrollListener({
onScroll : function(view: any, firstVisibleItem: any, visibleItemCount: any, totalItemCount: any) : void {
// console.log('onScroll=> firstVisibleItem: ' + firstVisibleItem + ', totalItemCount: ' + totalItemCount);
if (firstVisibleItem === 0) {
}
currentFirstVisibleItem = firstVisibleItem;
currentVisibleItemCount = visibleItemCount;
currentTotalItemCount = totalItemCount;
},
onScrollStateChanged : function(view: any, scrollState: any) : void {
currentScrollState = scrollState;
// SCROLL_STATE_IDLE = 0
if (currentVisibleItemCount > 0 && currentScrollState === 0) {
if (currentFirstVisibleItem === 0) {
that.loadMorePlayersTop();
console.log('LOAD MORE...');
}
}
}
})
this.listView.android.setOnScrollListener(listener);
} else {
const newDelegate: any = NewUITableViewDelegateImpl.initWithOriginalDelegate
((<any>this.listView)._delegate, this.loadMorePlayersTop.bind(this));
(<any>this.listView)._delegate = newDelegate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment