Skip to content

Repository files navigation

Introduction

An implementation of Coil's Decoder to support animated WebP on Android of which sdk version is less than 28. It depends on libwebp as a native library.

Setup

In your settings.gradle

dependencyResolutionManagement {
    repositories {
        maven {
            url "https://maven.pkg.github.com/skgmn/AnimatedWebPDecoder"
            credentials {
                username <Your GitHub ID>
                password <Your GitHub Personal Access Token>
            }
        }
    }
}

In your app/build.gradle

dependencies {
    implementation "com.github.skgmn:animatedwebpdecoder:0.1.2"
}

How to use

Simply add AnimatedWebPDecoder to your ImageLoader.Builder. As stated in here, it is recommended to use with io.coil-kt:coil-gif.

val imageLoader = ImageLoader.Builder(context)
    .componentRegistry {
        if (SDK_INT >= 28) {
            add(ImageDecoderDecoder(context))
        } else {
            add(AnimatedWebPDecoder())
        }
    }
    .build()

Proguard rules

As it uses native library, it also needs proguard rules. Add these rules to your proguard-rules.pro.

-keep class com.github.skgmn.webpdecoder.libwebp.LibWebPAnimatedDecoder {
    java.nio.ByteBuffer byteBuffer;
    native <methods>;
}

-keep class com.github.skgmn.webpdecoder.libwebp.LibWebPAnimatedDecoder$Metadata {
    *;
}

About

A decoder implementation for Coil to support animated WebP format on Android of which sdk version < 28

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages