Subgroup sub image url, ImageVariable default error icon on fail to load

This commit is contained in:
Kelvin 2025-03-10 22:12:17 +01:00
parent 06478f3e36
commit 7c25678211
7 changed files with 17 additions and 7 deletions

View file

@ -256,6 +256,8 @@ class SubscriptionGroupFragment : MainFragment() {
val sub = StateSubscriptions.instance.getSubscription(sub) ?: StateSubscriptions.instance.getSubscriptionOther(sub);
if(sub != null && sub.channel.thumbnail != null) {
g.image = ImageVariable.fromUrl(sub.channel.thumbnail!!);
if(g.image != null)
g.image!!.subscriptionUrl = sub.channel.url;
g.image?.setImageView(_imageGroup);
g.image?.setImageView(_imageGroupBackground);
break;

View file

@ -7,6 +7,7 @@ import android.widget.ImageView
import com.bumptech.glide.Glide
import com.futo.platformplayer.PresetImages
import com.futo.platformplayer.R
import com.futo.platformplayer.logging.Logger
import kotlinx.serialization.Contextual
import kotlinx.serialization.Transient
import java.io.File
@ -18,7 +19,8 @@ data class ImageVariable(
@Transient
@Contextual
private val bitmap: Bitmap? = null,
val presetName: String? = null) {
val presetName: String? = null,
var subscriptionUrl: String? = null) {
@SuppressLint("DiscouragedApi")
fun setImageView(imageView: ImageView, fallbackResId: Int = -1) {
@ -63,7 +65,13 @@ data class ImageVariable(
return ImageVariable(null, null, null, str);
}
fun fromFile(file: File): ImageVariable {
return ImageVariable.fromBitmap(BitmapFactory.decodeFile(file.absolutePath));
try {
return ImageVariable.fromBitmap(BitmapFactory.decodeFile(file.absolutePath));
}
catch(ex: Throwable) {
Logger.e("ImageVariable", "Unsupported image format? " + ex.message, ex);
return fromResource(R.drawable.ic_error_pred);
}
}
}
}

@ -1 +1 @@
Subproject commit 0d05e35cfc81acfa78594c91c381b79694aaf86d
Subproject commit 9c36c457463fc2a452f76eb74465e9e234cdaf69

@ -1 +1 @@
Subproject commit 857c147b3a3d3e9d0a79c47f1bd5813e08ed2daf
Subproject commit 6e0fe9245143336a31954d678cdd22cbc3e0e115

@ -1 +1 @@
Subproject commit 0d05e35cfc81acfa78594c91c381b79694aaf86d
Subproject commit 9c36c457463fc2a452f76eb74465e9e234cdaf69

@ -1 +1 @@
Subproject commit 857c147b3a3d3e9d0a79c47f1bd5813e08ed2daf
Subproject commit 6e0fe9245143336a31954d678cdd22cbc3e0e115

@ -1 +1 @@
Subproject commit 44edd69ece9cac4a6dd95a84ca91299e44f3650a
Subproject commit f87f00ab9e1262e300246b8963591bdf3a8fada7