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 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt') 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 -- cgit v1.2.3