use of com.bumptech.glide.request.target.SizeReadyCallback in project GestureViews by alexvasilkov.
the class GlideHelper method loadResource.
public static void loadResource(@DrawableRes int drawableId, @NonNull ImageView image) {
DisplayMetrics metrics = image.getResources().getDisplayMetrics();
final int displayWidth = metrics.widthPixels;
final int displayHeight = metrics.heightPixels;
Glide.with(image.getContext()).load(drawableId).asBitmap().dontAnimate().diskCacheStrategy(DiskCacheStrategy.NONE).into(new BitmapImageViewTarget(image) {
@Override
public void getSize(final SizeReadyCallback cb) {
// We don't want to load very big images on devices with small screens.
// This will help Glide correctly choose images scale when reading them.
super.getSize(new SizeReadyCallback() {
@Override
public void onSizeReady(int width, int height) {
cb.onSizeReady(displayWidth / 2, displayHeight / 2);
}
});
}
});
}
use of com.bumptech.glide.request.target.SizeReadyCallback in project glide by bumptech.
the class ListPreloaderTest method getTargetsSizes.
private <R> List<Integer> getTargetsSizes(RequestBuilder<R> requestBuilder, VerificationMode mode) {
ArgumentCaptor<Integer> integerArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Target<R>> targetArgumentCaptor = cast(ArgumentCaptor.forClass(Target.class));
SizeReadyCallback cb = mock(SizeReadyCallback.class);
verify(requestBuilder, mode).into(targetArgumentCaptor.capture());
for (Target<R> target : targetArgumentCaptor.getAllValues()) {
target.getSize(cb);
}
verify(cb, mode).onSizeReady(integerArgumentCaptor.capture(), integerArgumentCaptor.capture());
return integerArgumentCaptor.getAllValues();
}
use of com.bumptech.glide.request.target.SizeReadyCallback in project glide by bumptech.
the class RequestFutureTargetTest method testCallsSizeReadyCallbackOnGetSize.
@Test
public void testCallsSizeReadyCallbackOnGetSize() {
SizeReadyCallback cb = mock(SizeReadyCallback.class);
future.getSize(cb);
verify(cb).onSizeReady(eq(width), eq(height));
}
Aggregations