penfeizhou / APNG4Android

Android animation support for APNG & Animated WebP & Gif & Animated AVIF, High performance
Apache License 2.0
570 stars 75 forks source link

Is there a way to use this with compose? #195

Closed JanB97 closed 1 year ago

JanB97 commented 1 year ago

Not an issue, but is there a way to use this with compose?

danipralea commented 1 year ago

I would very much like to know as well? Been struggling with it for more than 3 days now

penfeizhou commented 1 year ago

You can use Glide's GlideImage by implementation com.github.bumptech.glide:compose:1.0.0-alpha.6 Like this

@OptIn(ExperimentalGlideComposeApi::class)
@Composable
fun AnimationDemo() {
    Column(
        modifier = Modifier
            .verticalScroll(rememberScrollState())
            .fillMaxWidth()
            .fillMaxHeight()
            .padding(20.dp)
    ) {
        GlideImage(
            model = "file:///android_asset/1.webp",
            contentDescription = "Test",
        )
        GlideImage(
            model = "file:///android_asset/test1.png",
            contentDescription = "Test",
        )
        GlideImage(
            model = "file:///android_asset/2.gif",
            contentDescription = "Test",
        )
    }
}

You can refer to the following file: https://github.com/penfeizhou/APNG4Android/blob/master/app/src/main/java/com/github/penfeizhou/animation/demo/ComposeActivity.kt