Upgrade to Pro — share decks privately, control downloads, hide ads and more …

potatotips-33

Yuya Kaido
September 28, 2016

 potatotips-33

Yuya Kaido

September 28, 2016
Tweet

More Decks by Yuya Kaido

Other Decks in Programming

Transcript

  1. εΫϩʔϧΠϕϯτ 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. 

  3. ΫϩʔδϟͰͷঢ়ଶ؅ཧ 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