Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ import com.lagradost.cloudstream3.utils.downloader.DownloadFileManagement.getFol
import com.lagradost.cloudstream3.utils.txt
import kotlinx.coroutines.Job
import kotlinx.coroutines.runBlocking
import java.util.concurrent.ConcurrentHashMap

/** Separate object with helper functions for the downloader */
object DownloadUtils {
private val cachedBitmaps = hashMapOf<String, Bitmap>()
private val cachedBitmaps = ConcurrentHashMap<String, Bitmap>()
internal fun Context.getImageBitmapFromUrl(
url: String,
headers: Map<String, String>? = null
): Bitmap? = safe {
if (cachedBitmaps.containsKey(url)) {
return@safe cachedBitmaps[url]
cachedBitmaps[url]?.let {
return@safe it
}

val imageLoader = SingletonImageLoader.get(this)
Expand All @@ -50,7 +51,7 @@ object DownloadUtils {
}

bitmap?.let {
cachedBitmaps[url] = it
cachedBitmaps.putIfAbsent(url, it)
}

return@safe bitmap
Expand Down