From e1af19b02444391cb02b1d9dd019296ecf152d2f Mon Sep 17 00:00:00 2001 From: Don Turner Date: Tue, 9 Feb 2021 16:02:35 +0000 Subject: [PATCH] Added timeout to album art download --- .../android/uamp/media/library/AlbumArtContentProvider.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/example/android/uamp/media/library/AlbumArtContentProvider.kt b/common/src/main/java/com/example/android/uamp/media/library/AlbumArtContentProvider.kt index b420789f..2c12b1ef 100644 --- a/common/src/main/java/com/example/android/uamp/media/library/AlbumArtContentProvider.kt +++ b/common/src/main/java/com/example/android/uamp/media/library/AlbumArtContentProvider.kt @@ -25,6 +25,7 @@ import android.os.ParcelFileDescriptor import com.bumptech.glide.Glide import java.io.File import java.io.FileNotFoundException +import java.util.concurrent.TimeUnit class AlbumArtContentProvider : ContentProvider() { @@ -57,7 +58,7 @@ class AlbumArtContentProvider : ContentProvider() { .asFile() .load(remoteUri) .submit() - .get() + .get(DOWNLOAD_TIMEOUT_SECONDS, TimeUnit.SECONDS) // Rename the file Glide created to match our own scheme. cacheFile.renameTo(file) @@ -89,3 +90,5 @@ class AlbumArtContentProvider : ContentProvider() { override fun getType(uri: Uri): String? = null } + +const val DOWNLOAD_TIMEOUT_SECONDS = 30L