From 3265956c1a74f2346c5f7fedaf938d71b69261ba Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Mon, 22 Feb 2021 01:02:53 +0100 Subject: Replacing null values by an "Unknown" string. --- .../aniki/topmanga/DetailTopMangaActivity.kt | 33 ++++++++++++++++++---- .../xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt | 2 +- 2 files changed, 29 insertions(+), 6 deletions(-) (limited to 'app/src/main') 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 b222a99..5749071 100644 --- a/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt +++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt @@ -72,10 +72,20 @@ class DetailTopMangaActivity : AppCompatActivity() { .apply(RequestOptions().override(400)) .into(ivImage) - //not used in the recyclerview - tvVolumes.text = mangaVolumes + //using null as a string because it has been converted to a string before + tvVolumes.text = if (mangaVolumes != "null"){ + mangaVolumes + } else { + fieldIsNull() + } + tvStartDate.text = mangaStartDate - tvEndDate.text = mangaEndDate + + tvEndDate.text = if (mangaEndDate != "null"){ + mangaEndDate + } else { + fieldIsNull() + } //taking the API's fields I want and displaying them makeApiCall(baseUrl, mangaId.toString()) @@ -116,13 +126,26 @@ class DetailTopMangaActivity : AppCompatActivity() { val tvSynopsis: TextView = findViewById(R.id.tv_synopsis) val tvBackground: TextView = findViewById(R.id.tv_background) - tvChapters.text = manga.chapters.toString() + tvChapters.text = if (manga.chapters != null){ + manga.chapters.toString() + } else { + fieldIsNull() + } + tvSynopsis.text = manga.synopsis.toString() - tvBackground.text = manga.background.toString() + + tvBackground.text = if (manga.background != null){ + manga.background.toString() + } else { + fieldIsNull() + } } fun showError(text: String) { Toast.makeText(this, text, Toast.LENGTH_LONG).show() } + fun fieldIsNull(): String{ + return "Unknown" + } } \ 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 c2b3567..c6fde13 100644 --- a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt +++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt @@ -70,7 +70,7 @@ class TopMangaAdapter(val mangaList: List) : putExtra(currentMangaImageUrl, currentManga.image_url.toString()) putExtra(currentMangaVolumes, currentManga.volumes.toString()) putExtra(currentMangaStartDate, currentManga.start_date) - putExtra(currentMangaEndDate, currentManga.end_date) + putExtra(currentMangaEndDate, currentManga.end_date.toString()) } holder.itemView.context.startActivity(intent) } -- cgit v1.2.3