Skip to content

Instantly share code, notes, and snippets.

@frel
Created August 15, 2021 10:41
Show Gist options
  • Save frel/f83c4216de15da8f317804851836d003 to your computer and use it in GitHub Desktop.
Save frel/f83c4216de15da8f317804851836d003 to your computer and use it in GitHub Desktop.
AirBrush Medium article example
class TinyThumbLoader : ModelLoader<TinyThumb, TinyThumb> {
override fun buildLoadData(
model: TinyThumb,
width: Int,
height: Int,
options: Options
) = ModelLoader.LoadData(
ObjectKey(model.toString()),
TinyThumbDataFetcher(model)
)
// Quick check to see if this model can be decoded
override fun handles(model: TinyThumb): Boolean = model.base64.isNotEmpty()
class Factory : ModelLoaderFactory<TinyThumb, TinyThumb> {
override fun build(multiFactory: MultiModelLoaderFactory) = TinyThumbLoader()
override fun teardown() { /* Do nothing */ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment