potatotips-33

836437265cbba12ee1b24bbb359a6c15?s=47 Yuya Kaido
September 28, 2016

 potatotips-33

836437265cbba12ee1b24bbb359a6c15?s=128

Yuya Kaido

September 28, 2016
Tweet

Transcript

  1. 6.

    εΫϩʔϧΠϕϯτ recyclerView.scrollEvents() .filter { RecyclerViewUtil.shouldPaginate(layoutManager) }
 .subscribe({
 // Load next

    page
 }) fun shouldPaginate(manager: LinearLayoutManager): Boolean {
 val totalItemCount = manager.itemCount - 1
 val lastVisibleItemPosition = manager.findLastVisibleItemPosition()
 return totalItemCount == lastVisibleItemPosition
 }  εΫϩʔϧͷݕ஌ ࠷Լ෦ͷ൑ఆ
  2. 9.

    

  3. 11.

    ΫϩʔδϟͰͷঢ়ଶ؅ཧ fun getFetcher(category: Category): () -> Observable<List<Article>> {
 var isFetching

    = false
 var offset = 0
 return fun () = Observable.just(isFetching)
 .filter { !isFetching }
 .doOnNext { isFetching = true }
 .flatMap { repository.getArticles(category, offset) }
 .doOnNext { isFetching = false }
 .doOnNext { offset += it.size }
 } • ಡΈࠐΈதϑϥάͱΦϑηοτΛ؅ཧ • ಡΈࠐΈதʹୟ͍ͯ΋Կ΋ى͜Βͳ͍ • Activity/Fragment͔ΒΈΔͱɺԿ΋ߟ͑ͣʹୟ͚͹OK