Fix crash when loading image that doesn't exist (#329)

* Wait until the image is downloaded

* Use timeout
This commit is contained in:
davidoskky 2021-01-10 21:14:23 +01:00 committed by GitHub
parent 25fd869c01
commit d89423b9ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,7 +156,7 @@ data class Item(
fun preloadImages(context: Context) : Boolean {
val imageUrls = this.getImages()
val glideOptions = RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.ALL)
val glideOptions = RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.ALL).timeout(10000)
try {
@ -164,7 +164,7 @@ data class Item(
if ( URLUtil.isValidUrl(url)) {
val image = Glide.with(context).asBitmap()
.apply(glideOptions)
.load(url).submit().get()
.load(url).submit()
}
}
} catch (e : Error) {