From 41bb476749fa84164726b728676b144531009446 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Fri, 19 Feb 2021 12:53:57 +0100 Subject: Deleting useless files and adding image support. --- app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt') diff --git a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt index 45e714a..ee8a510 100644 --- a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt +++ b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt @@ -48,27 +48,26 @@ class TopMangaPage : Fragment() { } fun makeApiCall(view: View, BASE_URL: String) { + val gson = GsonBuilder() .setLenient() .create() + val retrofit = Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create(gson)) .build() + val service = retrofit.create(TopMangaApi::class.java) val call = service.getTopMangaData() + call.enqueue(object : Callback { override fun onResponse(call: Call, response: Response) { - if(response.isSuccessful && response.body() != null){ - val topMangaResponse = response.body()!!.getResults() - Snackbar.make(requireView(), "HA? YOU THOUGHT IT WAS AN ERROR !? BUT IT WAS I, API !", Snackbar.LENGTH_LONG) - .setAction("Action", null).show() - // Retrieves data from mangasource - //val mangaList = MangaSource(view.context).getMangaList() - val mangaList=topMangaResponse - showList(view, mangaList) + if(response.isSuccessful && response.body() != null){ //if the code returned is >= 200 and < 300 AND the the body ain't empty + val mangaList = response.body()!!.getResults() //getting the "top" field containing our list of TopMangas + showList(view, mangaList) // calling the method in charge of displaying on the recyclerview } else { - showError() + showError() //a snackbar } } @@ -85,7 +84,7 @@ class TopMangaPage : Fragment() { } companion object { - var base_url = "https://api.jikan.moe/" + var base_url = "https://api.jikan.moe/" //the api's base url } } \ No newline at end of file -- cgit v1.2.3