daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package id.ihwan.aac.viewmodel
  2.  
  3. import android.app.Application
  4. import androidx.lifecycle.AndroidViewModel
  5. import androidx.lifecycle.MutableLiveData
  6. import id.ihwan.aac.model.MovieResponse
  7. import id.ihwan.aac.network.MainRepository
  8.  
  9. class MainViewModel(application: Application): AndroidViewModel(application) {
  10.  
  11.     private val repository = MainRepository()
  12.  
  13.     var movies : MutableLiveData<MovieResponse> = MutableLiveData()
  14.     var error: MutableLiveData<Throwable> = MutableLiveData()
  15.  
  16.     fun getMovie(){
  17.         repository.requestMovie({
  18.             movies.postValue(it)
  19.         },{
  20.             error.postValue(it)
  21.         })
  22.     }
  23.  
  24.     override fun onCleared() {
  25.         super.onCleared()
  26.         repository.onDestroy()
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top