set fallback placeholder for loadImage

set fallback placeholder if somehow null was passed as a placeholder

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-01-17 13:51:25 +01:00
parent 5ba6148273
commit 99c6d77b17
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -149,13 +149,17 @@ fun ImageView.loadThumbnail(url: String, user: User): io.reactivex.disposables.D
}
fun ImageView.loadImage(url: String, user: User, placeholder: Drawable? = null): io.reactivex.disposables.Disposable {
var finalPlaceholder = placeholder
if (finalPlaceholder == null) {
finalPlaceholder = ContextCompat.getDrawable(context!!, R.drawable.ic_mimetype_file)
}
val requestBuilder = ImageRequest.Builder(context)
.data(url)
.crossfade(true)
.target(this)
.placeholder(placeholder)
.error(placeholder)
.placeholder(finalPlaceholder)
.error(finalPlaceholder)
.transformations(RoundedCornersTransformation(ROUNDING_PIXEL, ROUNDING_PIXEL, ROUNDING_PIXEL, ROUNDING_PIXEL))
if (url.startsWith(user.baseUrl!!) &&