From f650e3b9d80633d90e13b07b64e5695564d37359 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Fri, 19 Feb 2021 12:00:30 +0100 Subject: Adaptation of the adapter, the rest response and the fragment. --- app/src/main/java/xyz/adjutor/aniki/MangaAdapter.kt | 8 ++++---- app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt | 6 +++--- app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'app/src/main/java/xyz/adjutor/aniki') diff --git a/app/src/main/java/xyz/adjutor/aniki/MangaAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/MangaAdapter.kt index 9f7a373..f378c65 100644 --- a/app/src/main/java/xyz/adjutor/aniki/MangaAdapter.kt +++ b/app/src/main/java/xyz/adjutor/aniki/MangaAdapter.kt @@ -6,9 +6,8 @@ import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView import androidx.recyclerview.widget.RecyclerView -import java.util.ArrayList -class MangaAdapter(val mangaList: Array) : +class MangaAdapter(val mangaList: List) : RecyclerView.Adapter() { // Describes an item view and its place within the RecyclerView @@ -34,8 +33,9 @@ class MangaAdapter(val mangaList: Array) : // Displays data at a certain position override fun onBindViewHolder(holder: MangaViewHolder, position: Int) { - holder.mangaTitle.text = mangaList[position] //use specific json data - holder.mangaRank.text = position.toString() //replace by the actual rank + val currentManga: TopManga = mangaList[position] + holder.mangaTitle.text = currentManga.title //use specific json data + holder.mangaRank.text = currentManga.rank.toString() //replace by the actual rank //holder.mangaImage.setImageResource(mangaList[position]) //replace by the manga image } } diff --git a/app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt index 46b3bd3..0a7ebc8 100644 --- a/app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt +++ b/app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt @@ -11,9 +11,9 @@ class RestTopMangaResponse { @SerializedName("request_cached_expiry") var request_cached_expiry: Int? = null @SerializedName("top") - var top = ArrayList() + var top: List? = null - fun getResults(): ArrayList { - return top + fun getResults(): List { + return top!! } } \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt index 729ff6f..45e714a 100644 --- a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt +++ b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt @@ -40,7 +40,7 @@ class TopMangaPage : Fragment() { } - fun showList(view: View, mangaList: Array ){ + fun showList(view: View, mangaList: List ){ val recyclerView: RecyclerView = view.findViewById(R.id.recycler_view) recyclerView.setHasFixedSize(true) recyclerView.layoutManager = LinearLayoutManager(view.context) @@ -64,7 +64,8 @@ class TopMangaPage : Fragment() { 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 = MangaSource(view.context).getMangaList() + val mangaList=topMangaResponse showList(view, mangaList) } else { showError() -- cgit v1.2.3