|
|
@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.Column |
|
|
|
import androidx.compose.foundation.layout.size |
|
|
|
import androidx.compose.foundation.layout.size |
|
|
|
import androidx.compose.material.CircularProgressIndicator |
|
|
|
import androidx.compose.material.CircularProgressIndicator |
|
|
|
import androidx.compose.material.Text |
|
|
|
import androidx.compose.material.Text |
|
|
|
|
|
|
|
import androidx.compose.runtime.getValue |
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
import androidx.compose.ui.graphics.ImageBitmap |
|
|
|
import androidx.compose.ui.graphics.ImageBitmap |
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
import androidx.compose.ui.unit.dp |
|
|
@ -16,16 +17,14 @@ import org.jetbrains.compose.resources.LoadState |
|
|
|
import org.jetbrains.compose.resources.load |
|
|
|
import org.jetbrains.compose.resources.load |
|
|
|
import org.jetbrains.compose.resources.loadOrNull |
|
|
|
import org.jetbrains.compose.resources.loadOrNull |
|
|
|
|
|
|
|
|
|
|
|
fun main() = singleWindowApplication { |
|
|
|
private val url = |
|
|
|
val url = |
|
|
|
|
|
|
|
"https://raw.githubusercontent.com/JetBrains/skija/ccf303ebcf926e5ef000fc42d1a6b5b7f1e0b2b5/examples/scenes/images/codecs/animated.gif" |
|
|
|
"https://raw.githubusercontent.com/JetBrains/skija/ccf303ebcf926e5ef000fc42d1a6b5b7f1e0b2b5/examples/scenes/images/codecs/animated.gif" |
|
|
|
|
|
|
|
|
|
|
|
// Load an image async |
|
|
|
fun main() = singleWindowApplication { |
|
|
|
val animatedImage = |
|
|
|
|
|
|
|
load { loadAnimatedImage(url) } // use "load { loadResourceAnimatedImage(url) }" for resources |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Column { |
|
|
|
Column { |
|
|
|
when (animatedImage) { |
|
|
|
// Load an image async |
|
|
|
|
|
|
|
// use "load { loadResourceAnimatedImage(url) }" for resources |
|
|
|
|
|
|
|
when (val animatedImage = load { loadAnimatedImage(url) }) { |
|
|
|
is LoadState.Success -> Image( |
|
|
|
is LoadState.Success -> Image( |
|
|
|
bitmap = animatedImage.value.animate(), |
|
|
|
bitmap = animatedImage.value.animate(), |
|
|
|
contentDescription = null, |
|
|
|
contentDescription = null, |
|
|
@ -34,7 +33,6 @@ fun main() = singleWindowApplication { |
|
|
|
is LoadState.Error -> Text("Error!") |
|
|
|
is LoadState.Error -> Text("Error!") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Column { |
|
|
|
|
|
|
|
Image( |
|
|
|
Image( |
|
|
|
loadOrNull { loadAnimatedImage(url) }?.animate() ?: ImageBitmap.Blank, |
|
|
|
loadOrNull { loadAnimatedImage(url) }?.animate() ?: ImageBitmap.Blank, |
|
|
|
contentDescription = null, |
|
|
|
contentDescription = null, |
|
|
@ -42,4 +40,3 @@ fun main() = singleWindowApplication { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|