Last active
December 23, 2017 10:50
-
-
Save Pooh3Mobi/40f369265136d3c0b4129d959113e33c to your computer and use it in GitHub Desktop.
List -> itr -> toList -> subscribe -> recyclerview.adapter = adapter
This file contains 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
class TpcsFgmt : Fragment() { | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
val sLoadingVisible = RxView.visibility(loadingTextView, View.INVISIBLE) | |
val sRVVisible = RxView.visibility(list, View.INVISIBLE) | |
val sIsLoading = BehaviorSubject.createDefault(false) | |
sIsLoading.observeOn(AndroidSchedulers.mainThread()).subscribe { loading -> | |
sLoadingVisible.accept(loading) | |
sRVVisible.accept(!loading) | |
} | |
Zaif.client.currencyPairObs() | |
.doOnSubscribe { sIsLoading.onNext(true) } | |
.doAfterTerminate{ sIsLoading.onNext(false) } | |
.flatMapIterable { data -> data } | |
.map { item -> convertTpcItem(item) } | |
.toList() | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe { items -> | |
list.layoutManager = LMng(view.context) | |
list.adapter = TpcsAdptr( | |
items, | |
createVH = { vg -> vg.createVH(R.layout.vh_tpc, sIntrvl, sRng) }, | |
bindVH = { tpc, vh -> | |
vh.ttl.text = tpc.ttl | |
vh.dtil.text = tpc.dtil | |
vh.item = tpc | |
}, | |
itemCnt = { cchdItems -> cchdItems.size } | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment