From 94ab3bbeb21049ac1be128ee00dbae1570346123 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Sun, 21 Feb 2021 18:24:25 +0100 Subject: Displaying the other infos from the TopManga API. --- .../xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt | 16 ++++++++++++++++ .../java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt | 6 ++++++ .../main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/xyz/adjutor/aniki/topmanga') diff --git a/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt b/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt index 9347f2c..27f602a 100644 --- a/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt +++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt @@ -17,6 +17,10 @@ class DetailTopMangaActivity : AppCompatActivity() { private val mangaScore = "themangascore" private val mangaImageUrl = "themangaimageurl" + private val mangaVolumes = "themangavolumes" + private val mangaStartDate = "themangastartdate" + private val mangaEndDate = "themangaenddate" + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_detail_top_manga) @@ -27,12 +31,20 @@ class DetailTopMangaActivity : AppCompatActivity() { val mangaScore = intent.getStringExtra(mangaScore) val mangaImage = intent.getStringExtra(mangaImageUrl) + val mangaVolumes = intent.getStringExtra(mangaVolumes) + val mangaStartDate = intent.getStringExtra(mangaStartDate) + val mangaEndDate = intent.getStringExtra(mangaEndDate) + val tvId: TextView = findViewById(R.id.tv_detail_id) val tvTitle: TextView = findViewById(R.id.tv_detail_title) val tvRank: TextView = findViewById(R.id.tv_detail_rank) val tvScore: TextView = findViewById(R.id.tv_detail_score) val ivImage: ImageView = findViewById(R.id.iv_detail_image) + val tvVolumes: TextView = findViewById(R.id.tv_volumes) + val tvStartDate: TextView = findViewById(R.id.tv_start_date) + val tvEndDate: TextView = findViewById(R.id.tv_end_date) + //elements from Manga val tvChapters: TextView = findViewById(R.id.tv_chapters) val tvSynopsis: TextView = findViewById(R.id.tv_synopsis) @@ -47,5 +59,9 @@ class DetailTopMangaActivity : AppCompatActivity() { .load(mangaImage) .apply(RequestOptions().override(400)) .into(ivImage) + + tvVolumes.text = mangaVolumes + tvStartDate.text = mangaStartDate + tvEndDate.text = mangaEndDate } } \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt index e46fc79..7a32dd5 100644 --- a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt +++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt @@ -60,6 +60,9 @@ class TopMangaAdapter(val mangaList: List) : val currentMangaRank = "themangarank" val currentMangaScore = "themangascore" val currentMangaImageUrl = "themangaimageurl" + val currentMangaVolumes = "themangavolumes" + val currentMangaStartDate = "themangastartdate" + val currentMangaEndDate = "themangaenddate" val intent: Intent = Intent(holder.itemView.context, DetailTopMangaActivity::class.java).apply { putExtra(currentMangaId, currentManga.mal_id.toString()) @@ -67,6 +70,9 @@ class TopMangaAdapter(val mangaList: List) : putExtra(currentMangaRank, currentManga.rank.toString()) putExtra(currentMangaScore, currentManga.score.toString()) putExtra(currentMangaImageUrl, currentManga.image_url.toString()) + putExtra(currentMangaVolumes, currentManga.volumes.toString()) + putExtra(currentMangaStartDate, currentManga.start_date) + putExtra(currentMangaEndDate, currentManga.end_date) } holder.itemView.context.startActivity(intent) } diff --git a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt index 697ba6f..c560ffd 100644 --- a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt +++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt @@ -96,7 +96,7 @@ class TopMangaPage : Fragment() { val mangaList: List = response.body()!!.getResults() //getting the "top" field containing our list of TopMangas saveList(mangaList) - showList(view, mangaList) // calling the method in charge of displaying on the recyclerview + showList(view, mangaList) //calling the method in charge of displaying on the recyclerview } else { showError() //a snackbar @@ -120,7 +120,7 @@ class TopMangaPage : Fragment() { } private fun showError() { - Snackbar.make(requireView(), "HA? YOU THOUGHT IT WAS AN API !? BUT IT WAS I, ERROR !", Snackbar.LENGTH_LONG) + Snackbar.make(requireView(), "API ERROR", Snackbar.LENGTH_LONG) .setAction("Action", null).show() } -- cgit v1.2.3