Created
January 2, 2019 15:02
-
-
Save raghunandankavi2010/554bfcd0afda79d3fd26b196c2660b79 to your computer and use it in GitHub Desktop.
koin
This file contains hidden or 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 ListRepositoryImpl(private val retrofitDependency: RetrofitDependency): ListRepository { | |
var data = MutableLiveData<List<Users>>() | |
override fun getUsers(): MutableLiveData<List<Users>>{ | |
val service = retrofitDependency.provideRetrofit().create(Api::class.java) | |
service.users.enqueue(object : Callback<List<Users>> { | |
override fun onResponse(call: Call<List<Users>>, response: Response<List<Users>>) { | |
if (response.isSuccessful) { | |
val list = response.body() | |
data.value= (list!!) | |
} | |
} | |
override fun onFailure(call: Call<List<Users>>, t: Throwable) { | |
t.printStackTrace() | |
} | |
}) | |
return data | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment