Last active
September 28, 2018 07:57
-
-
Save marcel-ploch/6adf57e2b60c51f640d4ae7ec1ecd88e to your computer and use it in GitHub Desktop.
Register Listener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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