Fix person placeholder drawable
This commit is contained in:
parent
7d9857d3ce
commit
b9e5c3b9ba
1 changed files with 8 additions and 5 deletions
|
@ -2,6 +2,7 @@ package dev.jdtech.jellyfin
|
|||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.databinding.BindingAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
|
@ -55,7 +56,7 @@ fun bindItemBackdropById(imageView: ImageView, itemId: UUID) {
|
|||
@BindingAdapter("personImage")
|
||||
fun bindPersonImage(imageView: ImageView, person: BaseItemPerson) {
|
||||
imageView
|
||||
.loadImage("/items/${person.id}/Images/${ImageType.PRIMARY}")
|
||||
.loadImage("/items/${person.id}/Images/${ImageType.PRIMARY}", R.drawable.person_placeholder)
|
||||
.posterDescription(person.name)
|
||||
}
|
||||
|
||||
|
@ -102,7 +103,7 @@ fun bindSeasonPoster(imageView: ImageView, seasonId: UUID) {
|
|||
imageView.loadImage("/items/${seasonId}/Images/${ImageType.PRIMARY}")
|
||||
}
|
||||
|
||||
private fun ImageView.loadImage(url: String, errorPlaceHolderId: Int? = null): View {
|
||||
private fun ImageView.loadImage(url: String, @DrawableRes errorPlaceHolderId: Int? = null): View {
|
||||
val api = JellyfinApi.getInstance(context.applicationContext)
|
||||
|
||||
return Glide
|
||||
|
@ -110,15 +111,17 @@ private fun ImageView.loadImage(url: String, errorPlaceHolderId: Int? = null): V
|
|||
.load("${api.api.baseUrl}$url")
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
.placeholder(R.color.neutral_800)
|
||||
.also { if (errorPlaceHolderId != null) error(errorPlaceHolderId) }
|
||||
.error(errorPlaceHolderId)
|
||||
.into(this)
|
||||
.view
|
||||
}
|
||||
|
||||
private fun View.posterDescription(name: String?) {
|
||||
contentDescription = String.format(context.resources.getString(R.string.image_description_poster), name)
|
||||
contentDescription =
|
||||
String.format(context.resources.getString(R.string.image_description_poster), name)
|
||||
}
|
||||
|
||||
private fun View.backdropDescription(name: String?) {
|
||||
contentDescription = String.format(context.resources.getString(R.string.image_description_backdrop), name)
|
||||
contentDescription =
|
||||
String.format(context.resources.getString(R.string.image_description_backdrop), name)
|
||||
}
|
Loading…
Reference in a new issue