Giphy / giphy-android-sdk

Home of the GIPHY SDK Android example app, along with Android SDK documentation, issue tracking, & release notes.
https://developers.giphy.com/
Mozilla Public License 2.0
94 stars 37 forks source link

Gifloaded callback returns -1 as loop-duration #218

Closed ygag-gopikrishnan closed 7 months ago

ygag-gopikrishnan commented 7 months ago

🐛 Bug Report

object : GifView.GifCallback {
                    override fun onFailure(throwable: Throwable?) {

                    }

                    override fun onImageSet(imageInfo: ImageInfo?, anim: Animatable?, loopDuration: Long, loopCount: Int) {

                    }
                }

To Reproduce

@Composable
fun GifPreview(
    modifier: Modifier = Modifier,
    gifId: String,
    onGifLoaded: (
        durationInMillis: Long,
    ) -> Unit = {},
) {
    var isLoading by remember(gifId) {
        mutableStateOf(true)
    }

    AndroidView(
        modifier = Modifier
            .then(modifier)
            .shimmer(isLoading),
        factory = { context ->
            GPHMediaView(context)
        },
        update = { view ->
            with(view) {
                setMediaWithId(
                    gifId,
                    RenditionType.original,
                )
                setOnClickListener {
                    NoOperation
                }
                gifCallback = object : GifView.GifCallback {
                    override fun onFailure(throwable: Throwable?) {
                        isLoading = false
                    }

                    override fun onImageSet(imageInfo: ImageInfo?, anim: Animatable?, loopDuration: Long, loopCount: Int) {
                        isLoading = false
                        onGifLoaded(
                            loopDuration
                        )
                    }
                }
                setOnLongClickListener {
                    false
                }
            }
        }
    )
}

Expected behavior

(Write what you thought would happen.)

Actual Behavior

(Write what happened. Add screenshots, if applicable.)

Your Environment

Reproducible Demo