Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * initialize all resources
- * set current page to 1
- * create paginator and subscribe to events
- */
- override fun initialize() {
- currentPage = 1
- paginator = PublishProcessor.create()
- val d = paginator.onBackpressureDrop()
- .doOnNext { view.showProgress() }
- .concatMap { contract.getItemsFromServer(it) }
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe({
- view.hideProgress()
- view.showItems(it)
- currentPage++
- }, {
- view.hideProgress()
- view.showError(it.localizedMessage)
- })
- disposables.add(d)
- onLoadMore(currentPage)
- }
- /**
- * called when list is scrolled to its bottom
- * @param page current page (not used)
- */
- override fun onLoadMore(page: Int) {
- paginator.onNext(currentPage)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement