forked from omni/OmniCards
feat: added parallel icons loading
This commit is contained in:
@@ -54,6 +54,7 @@ import io.ktor.client.engine.cio.CIO
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.HttpResponse
|
||||
import io.ktor.client.statement.bodyAsText
|
||||
import kotlinx.coroutines.launch
|
||||
import ru.omni_devel.cards.ui.theme.OmniCardsTheme
|
||||
|
||||
class SelectIconActivity : ComponentActivity() {
|
||||
@@ -94,11 +95,13 @@ fun SelectIconPage(innerPadding: PaddingValues) {
|
||||
|
||||
for (iconData in loadedIconsData) {
|
||||
if (iconData.iconId != null) {
|
||||
val response = client.get("$REPO_BASE_URL/icons/${iconData.iconId}.png")
|
||||
val bytes: ByteArray = response.body()
|
||||
launch {
|
||||
val response = client.get("$REPO_BASE_URL/icons/${iconData.iconId}.png")
|
||||
val bytes: ByteArray = response.body()
|
||||
|
||||
BitmapFactory.decodeByteArray(bytes, 0, bytes.size)?.let { bitmap ->
|
||||
loadedIcons[iconData.iconId] = bitmap.asImageBitmap()
|
||||
BitmapFactory.decodeByteArray(bytes, 0, bytes.size)?.let { bitmap ->
|
||||
loadedIcons[iconData.iconId] = bitmap.asImageBitmap()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user