aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2021-02-19 12:00:30 +0100
committerClyhtsuriva <aimeric@adjutor.xyz>2021-02-19 12:02:22 +0100
commitf650e3b9d80633d90e13b07b64e5695564d37359 (patch)
tree8ad2f61fa3567012475a6c8660c2376092f684e8 /app/src/main/java
parenteaef2672c25baaf370c72158d5236f40f6fea01f (diff)
Adaptation of the adapter, the rest response and the fragment.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/MangaAdapter.kt8
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/RestTopMangaResponse.kt6
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt5
3 files changed, 10 insertions, 9 deletions
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<String>) :
+class MangaAdapter(val mangaList: List<TopManga>) :
RecyclerView.Adapter<MangaAdapter.MangaViewHolder>() {
// Describes an item view and its place within the RecyclerView
@@ -34,8 +33,9 @@ class MangaAdapter(val mangaList: Array<String>) :
// 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<TopManga>()
+ var top: List<TopManga>? = null
- fun getResults(): ArrayList<TopManga> {
- return top
+ fun getResults(): List<TopManga> {
+ 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<String> ){
+ fun showList(view: View, mangaList: List<TopManga> ){
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()