From 296f58a0b2df75923f9dcdcedcbe89dbc9291f08 Mon Sep 17 00:00:00 2001
From: Jace <54625750+Jacekun@users.noreply.github.com>
Date: Tue, 11 Jan 2022 20:53:08 +0800
Subject: [PATCH] Add default cover when posterUrl is null or empty (#423)
* add default cover image for when posterUrl is null or empty.
* show monke image on load when posterUrl is null or empty. Also, shows 'No Episodes found'on Tv Series when ep count is 0
* replace default cover image
---
.../cloudstream3/ui/result/ResultFragment.kt | 21 +++++++++++++++----
.../ui/search/SearchResultBuilder.kt | 6 +++++-
app/src/main/res/drawable/default_cover.xml | 20 ++++++++++++++++++
app/src/main/res/values/strings.xml | 1 +
4 files changed, 43 insertions(+), 5 deletions(-)
create mode 100644 app/src/main/res/drawable/default_cover.xml
diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt
index 0d7049fe..78a25eed 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt
@@ -1095,6 +1095,15 @@ class ResultFragment : Fragment() {
}
result_info?.isVisible = api.providerType == ProviderType.MetaProvider
+ if (d.type.isEpisodeBased()) {
+ val ep = d as? TvSeriesLoadResponse
+ val epCount = ep?.episodes?.size ?: 1
+ if (epCount < 1) {
+ result_info?.text = getString(R.string.no_episodes_found)
+ result_info?.isVisible = true
+ }
+ }
+
currentHeaderName = d.name
currentType = d.type
@@ -1158,11 +1167,15 @@ class ResultFragment : Fragment() {
result_meta_site?.text = d.apiName
- result_poster?.setImage(d.posterUrl)
- result_poster_blur?.setImageBlur(d.posterUrl, 10, 3)
+ if (!d.posterUrl.isNullOrEmpty()) {
+ result_poster?.setImage(d.posterUrl)
+ result_poster_blur?.setImageBlur(d.posterUrl, 10, 3)
+ } else {
+ result_poster?.setImageResource(R.drawable.default_cover)
+ result_poster_blur?.setImageResource(R.drawable.default_cover)
+ }
- result_poster_holder?.visibility =
- if (d.posterUrl.isNullOrBlank()) GONE else VISIBLE
+ result_poster_holder?.visibility = VISIBLE
result_play_movie?.text =
if (d.type == TvType.Torrent) getString(R.string.play_torrent_button) else getString(
diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt
index 4199032a..64d7fcd2 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt
@@ -48,7 +48,11 @@ object SearchResultBuilder {
cardText?.text = card.name
//imageTextProvider.text = card.apiName
- cardView.setImage(card.posterUrl)
+ if (!card.posterUrl.isNullOrEmpty()) {
+ cardView.setImage(card.posterUrl)
+ } else {
+ cardView.setImageResource(R.drawable.default_cover)
+ }
bg.setOnClickListener {
clickCallback.invoke(
diff --git a/app/src/main/res/drawable/default_cover.xml b/app/src/main/res/drawable/default_cover.xml
new file mode 100644
index 00000000..193fa46b
--- /dev/null
+++ b/app/src/main/res/drawable/default_cover.xml
@@ -0,0 +1,20 @@
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9900f871..13989ca2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -223,6 +223,7 @@
Episodes
S
E
+ No Episodes found
Delete File
Delete