Last active
October 7, 2024 14:09
-
-
Save AndreVero/7a7d4a5da54c577eb46ddfc1055b9e82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val hashMap = ConcurrentHashMap<String, Bitmap?>() | |
job = scope.launch { | |
val bitmap = if (hashMap.containsKey(url)) { | |
hashMap[url] | |
} else { | |
val bitmap = loadBitmap(url) | |
if (!hashMap.containsKey(url)) { | |
hashMap[url] = bitmap | |
bitmap | |
} else { | |
hashMap[url] | |
} | |
} | |
withContext(Dispatchers.Main) { | |
setImageBitmap(bitmap) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment