Skip to content

Instantly share code, notes, and snippets.

Created September 20, 2018 20:07
What would you like to do?
package com.illuzor.lesson.wallpapers.model
import com.illuzor.lesson.wallpapers.api.api
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
class ViewModelCategories : ViewModelBase() {
lateinit var data: List<Category>
private set
fun load() {
state = State.PROGRESS
api.categories().enqueue(object : Callback<List<Category>> {
override fun onResponse(call: Call<List<Category>>, response: Response<List<Category>>) {
data = response.body()!!
state = State.LOADED
override fun onFailure(call: Call<List<Category>>, t: Throwable?) {
state = State.ERROR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment