Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DetailViewModel : ViewModel() {
- private val repository: Repository = Repository()
- private val detailLeague: MutableLiveData<ListDetailLeague> = MutableLiveData()
- fun getDetailLeague(id: Int): LiveData<ListDetailLeague> {
- if(detailLeague.value == null) setDataDetailLeague(id)
- return detailLeague
- }
- var showLoading: MutableLiveData<Boolean> = MutableLiveData()
- var isError: MutableLiveData<Boolean> = MutableLiveData()
- private fun setDataDetailLeague(id: Int){
- showLoading.value = true
- repository.getDetailLeagueRepository(id, object : DetailLeagueCallback {
- override fun onSuccess(response: ListDetailLeague) {
- showLoading.value = false
- detailLeague.value = response
- }
- override fun onError() {
- showLoading.value = false
- isError.value = true
- }
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement