aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2021-05-14 14:27:11 +0200
committerClyhtsuriva <aimeric@adjutor.xyz>2021-05-14 14:27:11 +0200
commit6484782745a29752cf2a9a5015b34494513eb376 (patch)
treec9b4af4deb4acbac4c394e48d3df7874120d24a1 /app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt
parenta4fbe1308bb4cf61358d8169dd32505e2783a9af (diff)
parente3104c145727c10ff80cad0fe1e916a0a45239eb (diff)
Merge branch 'release/3.1'v3.1.0
Diffstat (limited to 'app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt37
1 files changed, 15 insertions, 22 deletions
diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt
index 845e750..ea631fd 100644
--- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt
@@ -9,9 +9,7 @@ import com.google.gson.reflect.TypeToken
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
-import retrofit2.Retrofit
-import retrofit2.converter.gson.GsonConverterFactory
-import xyz.adjutor.aniki.data.manga.TopMangaApi
+import xyz.adjutor.aniki.presentation.Singletons
import xyz.adjutor.aniki.presentation.model.manga.TopManga
import xyz.adjutor.aniki.presentation.model.manga.TopMangaResponse
import xyz.adjutor.aniki.presentation.view.manga.TopMangaPage
@@ -48,25 +46,20 @@ class TopMangaController {
private fun makeApiCall(view: TopMangaPage, BASE_URL: String, page: Int) {
- val retrofit = Retrofit.Builder()
- .baseUrl(BASE_URL)
- .addConverterFactory(GsonConverterFactory.create(gson))
- .build()
-
- val service = retrofit.create(TopMangaApi::class.java)
- val call = service.getTopMangaData(page)
-
- call.enqueue(object : Callback<TopMangaResponse> {
- override fun onResponse(
- call: Call<TopMangaResponse>,
- response: Response<TopMangaResponse>
- ) {
- if (response.isSuccessful && response.body() != null) { //if the code returned is >= 200 and < 300 AND the the body ain't empty
-
- val mangaList: List<TopManga> = response.body()!!
- .getResults() //getting the "top" field containing our list of TopMangas
- saveList(mangaList)
- view.showList(
+ Singletons
+ .topMangaApi
+ .getTopMangaData(page)
+ .enqueue(object : Callback<TopMangaResponse> {
+ override fun onResponse(
+ call: Call<TopMangaResponse>,
+ response: Response<TopMangaResponse>
+ ) {
+ if (response.isSuccessful && response.body() != null) { //if the code returned is >= 200 and < 300 AND the the body ain't empty
+
+ val mangaList: List<TopManga> = response.body()!!
+ .getResults() //getting the "top" field containing our list of TopMangas
+ saveList(mangaList)
+ view.showList(
view.requireView(),
mangaList
) //calling the method in charge of displaying on the recyclerview