aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2021-02-22 01:02:53 +0100
committerClyhtsuriva <aimeric@adjutor.xyz>2021-02-22 01:02:53 +0100
commit3265956c1a74f2346c5f7fedaf938d71b69261ba (patch)
tree8227a831400a5ed341cd23c74125da05a114b9e7 /app/src/main
parenta079577ca21e16dd4b424eea28498f7b56a297df (diff)
Replacing null values by an "Unknown" string.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt33
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt2
2 files changed, 29 insertions, 6 deletions
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<TopManga>) :
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)
}