AsapImageProviderExtensionProxy
AsapImagePorterExtendedProxy defines an image-loading interface, which enables custom loading of images by implementing and registering the interface.
Interface signature
copy
interface AsapImageProviderExtensionProxy: AsapExtensionProxy {
fun loadImage(content: Context, url: String, into: ImageView, with: Int, height: Int)
fun loadBackground(content: Context, url: String, into: View, with: Int, height: Int)
}
Method
Method name | Description |
loadImage | Implements the image loading function. |
loadBackground | Implements the background image loading function. |
Parameters
Field | Data type | Description |
context | Context | The context in which images are loaded. |
url | String | The URL that specifies the location of the image to be loaded. |
into | ImageView / View | The view that the loaded image fills. |
width | Int | The expected width for filling the view. |
height | Int | The expected height for filling the view. |
Samples
copy
@AsapExtension(proxyClazz = AsapImageProviderExtensionProxy.class)
public class ImageProvider implements AsapImageProviderExtensionProxy {
@Override
public void loadImage(@NonNull Context content, @NonNull String url, @NonNull ImageView into, int with, int height) {
Glide.with(content).load(url).into(into);
}
@Override
public void loadBackground(@NonNull Context content, @NonNull String url, @NonNull View into, int with, int height) {
Glide.with(content)
.asBitmap()
.override(with, height)
.load(url).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
into.setBackground(new BitmapDrawable(content.getResources(), bitmap));
}
});
}
}