Coilifier-Android is an open source extension library for Android to use Glide in a more Coil way
- ImageView extension functions
- Target extension functions
- provides Kotlin Builder DSL
Glide > https://github.com/bumptech/glide
Coil > https://github.com/coil-kt/coil
Add this line in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url = uri("https://jitpack.io") }
...
}
}
Add this line in your app build.gradle:
dependencies {
...
implementation("com.github.DatL4g:Coilifier-Android:1.0.0")
...
}
The goal is to bring Glide closer to the style of Coil. Glide usually loads faster than Coil (which I especially notice in RecyclerViews) but the Extension Function in Coil is much more innovative. And to get the best out of both, I created this library
Multiple ResourceType implementations in load functions is provided
Glide | Coilifier |
---|---|
Glide.with(this).as(Drawable::class.java).load(any).into(target) |
target.load<Drawable>(any) |
Glide.with(this).as(Bitmap::class.java).load(any).into(target) |
target.load<Bitmap>(any) |
Glide.with(this).as(File::class.java).load(any).into(target) |
target.load<File>(any) |
Glide.with(this).as(GifDrawable::class.java).load(any).into(target) |
target.load<GifDrawable>(any) |
Glide.with(this).as(Custom::class.java).load(any).into(target) |
target.load<Custom>(any) |
Glide | Coilifier |
---|---|
Glide.with(this).asDrawable().load(any).into(target) |
target.loadDrawable(any) |
Glide.with(this).asBitmap().load(any).into(target) |
target.loadBitmap(any) |
Glide.with(this).asFile().load(any).into(target) |
target.loadFile(any) |
Glide.with(this).asGif().load(any).into(target) |
target.loadGif(any) |
Available functions
error(resId: Int)
error(drawable: Drawable)
error(bitmap: Bitmap)
error(view: View)
// Captures View or gets current image of ImageViewplaceholder(resId: Int)
placeholder(drawable: Drawable)
placeholder(bitmap: Bitmap)
placeholder(view: View)
// Captures View or gets current image of ImageViewthumbnail(sizeMultiplier: Float)
thumbnail(vararg requestBuilder: RequestBuilder<ResourceType>)
transition(transitionOptions: TransitionOptions<*, in ResourceType?>)
transform(vararg transformations: Transformation<Bitmap?>)
scaleType(scale: Scale)
fitCenter()
centerCrop()
centerInside()
circleCrop()
optionalFitCenter()
optionalCenterCrop()
optionalCenterInside()
optionalCircleCrop()
apply(requestOptions: BaseRequestOptions<*>)
target.load<Drawable>(any) {
fitCenter()
transform(RoundedCorners(25))
}
// equals
Glide.with(this).asDrawable().load(any).fitCenter().transform(RoundedCorners(25)).into(target)
This project is mantained by:
Avatar | Contributor |
---|---|
DatLag |
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -m 'Add some feature')
- Push your branch (git push origin my-new-feature)
- Create a new Pull Request
View full license here. In short:
A permissive license whose main conditions require preservation of copyright and license notices. Contributors provide an express grant of patent rights. Licensed works, modifications, and larger works may be distributed under different terms and without source code.