I was successful show animated webp using coil on image composable.
However, my goal is to only run this animated webp once.
Now it is repeating infinitely.
Is there a way?
Is my code.
class MainActivity : ComponentActivity() {
val resourceAnimated =
"https://www.bandisoft.com/honeycam/help/file_format/sample.webp"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
MyApp()
}
}
}
}
@Composable
private fun MyApp() {
val imageLoader = ImageLoader.Builder(this)
.components {
if (SDK_INT >= 28) {
add(ImageDecoderDecoder.Factory())
} else {
add(GifDecoder.Factory())
}
}
.build()
val painter = rememberAsyncImagePainter(
model = resourceAnimated,
imageLoader = imageLoader,
)
Test(painter)
}
@Composable
private fun Test(painter: AsyncImagePainter) {
Box(modifier = Modifier.padding(16.dp)) {
Image(
painter = painter, contentDescription = null,
modifier = Modifier.fillMaxSize()
)
}
}
repeatCount()
of ImageRequest.Builder extension function