Light weight Downloading library which manages its own Memory cache.
val stocker = Stocker.Builder(applicationContext)
.build()
stocker.fetch(ASSET_URL_AS_STRING) {(body, status, error) ->
if(status) {
// Url downloaded
}
}
// Stocker fetch will return a Request object. Just pass it onto the Stocker.cancel() method.
val request = stocker.fetch(ASSET_URL_AS_STRING) {(body, status, error) ->
if(status) {
// Url downloaded
}
}
stocker.cancel(request) // To cancel the request
Stocker.bind(IMAGE_URL_AS_STRING, imageView)
It will download and render the image asset on the ImageView
To use Stocker Library goto the Release page and download the aar.
Stocker manages Memory caching by default with the best fit Memory size for your device. If you want to change it you can do it the following way
val stocker = Stocker.Builder(applicationContext)
.cacheSettings(object: CacheSettings {
override fun getCacheStrategy(): CacheStrategy {
return CacheStrategy.MEM_CACHE
}
override fun getMemCacheSize(): Int {
return 10 * 1024 // 10MB
}
})
.build()
Stocker can also be configured without any caching
val stocker = Stocker.Builder(applicationContext)
.cacheSettings(object: CacheSettings {
override fun getCacheStrategy(): CacheStrategy {
return CacheStrategy.NO_CACHE
}
})
.build()
- Unit Testing
- Optimizing Image binding
- Publish to Gradle
You can also read about the Design decisions about the Sample app and Library inside the relevant folders README.