mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-03 09:28:18 +02:00
Better fixed avatar handling.
This commit is contained in:
parent
1306270887
commit
5e5ea32be1
@ -3,6 +3,8 @@ package com.vitorpamplona.amethyst
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.util.LruCache
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import java.util.UUID
|
||||
import name.neuhalfen.projects.android.robohash.RoboHash
|
||||
|
||||
@ -10,14 +12,18 @@ object RoboHashCache {
|
||||
|
||||
lateinit var robots: RoboHash
|
||||
|
||||
lateinit var defaultAvatar: ImageBitmap
|
||||
|
||||
@Synchronized
|
||||
fun get(context: Context, hash: String): Bitmap {
|
||||
fun get(context: Context, hash: String): ImageBitmap {
|
||||
if (!this::robots.isInitialized) {
|
||||
robots = RoboHash(context)
|
||||
robots.useCache(LruCache(100));
|
||||
//robots.useCache(LruCache(100));
|
||||
|
||||
defaultAvatar = robots.imageForHandle(robots.calculateHandleFromUUID(UUID.nameUUIDFromBytes("aaaa".toByteArray()))).asImageBitmap()
|
||||
}
|
||||
|
||||
return robots.imageForHandle(robots.calculateHandleFromUUID(UUID.nameUUIDFromBytes("aaaa".toByteArray())))
|
||||
return defaultAvatar
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user