1.9 KiB
1.9 KiB
AsyncDrawable.Loader
By default this library does not render any of the images. It's done to simplify rendering of text-based markdown. But if images must be supported, then the AsyncDrawable.Loader
can be specified whilst building a SpannableConfiguration
instance:
final AsyncDrawable.Loader loader = new AsyncDrawable.Loader() {
@Override
public void load(@NonNull String destination, @NonNull final AsyncDrawable drawable) {
// `download` method is here for demonstration purposes, it's not included in this interface
download(destination, new Callback() {
@Override
public void onDownloaded(Drawable d) {
// additionally we can call `drawable.isAttached()`
// to ensure if AsyncDrawable is in layout
drawable.setResult(d);
}
});
}
@Override
public void cancel(@NonNull String destination) {
// cancel download here
}
};
// `this` here referrs to a Context instance
final SpannableConfiguration configuration = SpannableConfiguration.builder(this)
.asyncDrawableLoader(loader)
.build();
There is also standalone artifact that supports image loading out-of-box (including support for SVG & GIF), but provides little to none configuration and could be somewhat not optimal. Please refer to the README of the module.