Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MovieHunt blog part4. list fragment
class MovieListFragment : BaseFragment(), MovieClickListener {
private val viewModel by sharedViewModel<MovieListViewModelV1>()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
...
viewModel.fetchMovieList(movieCategory)
viewModel.movieList
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnNext {
// Display paged list
...
}
.subscribe()
.disposeOnDestroy()
viewModel.refreshState
.observeOn(AndroidSchedulers.mainThread())
.doOnNext {
// Show/hide refresh progress
swipeRefresh.isRefreshing = (NetworkState.LOADING == it)
}
.subscribe()
.disposeOnDestroy()
viewModel.networkState
.observeOn(AndroidSchedulers.mainThread())
.doOnNext {
// Show/hide loading more progress
list.loadingMore = (NetworkState.LOADING == it)
}
.subscribe()
.disposeOnDestroy()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.