use of com.bumptech.glide.load.resource.bitmap.CenterCrop in project Signal-Android by WhisperSystems.
the class ThumbnailView method buildPlaceholderGlideRequest.
private RequestBuilder buildPlaceholderGlideRequest(@NonNull GlideRequests glideRequests, @NonNull Slide slide) {
GlideRequest<Bitmap> bitmap = glideRequests.asBitmap();
BlurHash placeholderBlur = slide.getPlaceholderBlur();
if (placeholderBlur != null) {
bitmap = bitmap.load(placeholderBlur);
} else {
bitmap = bitmap.load(slide.getPlaceholderRes(getContext().getTheme()));
}
return applySizing(bitmap.diskCacheStrategy(DiskCacheStrategy.NONE), new CenterCrop());
}
use of com.bumptech.glide.load.resource.bitmap.CenterCrop in project Signal-Android by WhisperSystems.
the class ThumbnailView method setImageResource.
public ListenableFuture<Boolean> setImageResource(@NonNull GlideRequests glideRequests, @NonNull Uri uri, int width, int height) {
SettableFuture<Boolean> future = new SettableFuture<>();
if (transferControls.isPresent())
getTransferControls().setVisibility(View.GONE);
GlideRequest request = glideRequests.load(new DecryptableUri(uri)).diskCacheStrategy(DiskCacheStrategy.NONE).transition(withCrossFade());
if (width > 0 && height > 0) {
request = request.override(width, height);
}
if (radius > 0) {
request = request.transforms(new CenterCrop(), new RoundedCorners(radius));
} else {
request = request.transforms(new CenterCrop());
}
request.into(new GlideDrawableListeningTarget(image, future));
blurhash.setImageDrawable(null);
return future;
}
use of com.bumptech.glide.load.resource.bitmap.CenterCrop in project Signal-Android by WhisperSystems.
the class BorderlessImageView method setSlide.
public void setSlide(@NonNull GlideRequests glideRequests, @NonNull Slide slide) {
boolean showControls = slide.asAttachment().getUri() == null;
if (slide.hasSticker()) {
image.setFit(new CenterInside());
image.setImageResource(glideRequests, slide, showControls, false);
} else {
image.setFit(new CenterCrop());
image.setImageResource(glideRequests, slide, showControls, false, slide.asAttachment().getWidth(), slide.asAttachment().getHeight());
}
missingShade.setVisibility(showControls ? View.VISIBLE : View.GONE);
}
use of com.bumptech.glide.load.resource.bitmap.CenterCrop in project Signal-Android by WhisperSystems.
the class ConversationListItem method createFinalBodyWithMediaIcon.
private static LiveData<CharSequence> createFinalBodyWithMediaIcon(@NonNull Context context, @NonNull String body, @NonNull ThreadRecord thread, @NonNull GlideRequests glideRequests, @Px int thumbSize, @NonNull GlideLiveDataTarget thumbTarget) {
if (thread.getSnippetUri() == null) {
return LiveDataUtil.just(body);
}
final String bodyWithoutMediaPrefix;
if (body.startsWith(EmojiStrings.GIF)) {
bodyWithoutMediaPrefix = body.replaceFirst(EmojiStrings.GIF, "");
} else if (body.startsWith(EmojiStrings.VIDEO)) {
bodyWithoutMediaPrefix = body.replaceFirst(EmojiStrings.VIDEO, "");
} else if (body.startsWith(EmojiStrings.PHOTO)) {
bodyWithoutMediaPrefix = body.replaceFirst(EmojiStrings.PHOTO, "");
} else if (thread.getExtra() != null && thread.getExtra().getStickerEmoji() != null && body.startsWith(thread.getExtra().getStickerEmoji())) {
bodyWithoutMediaPrefix = body.replaceFirst(thread.getExtra().getStickerEmoji(), "");
} else {
return LiveDataUtil.just(body);
}
glideRequests.asBitmap().load(new DecryptableStreamUriLoader.DecryptableUri(thread.getSnippetUri())).override(thumbSize, thumbSize).transform(new OverlayTransformation(ContextCompat.getColor(context, R.color.transparent_black_08)), new CenterCrop()).into(thumbTarget);
return Transformations.map(thumbTarget.getLiveData(), bitmap -> {
if (bitmap == null) {
return body;
}
RoundedDrawable drawable = RoundedDrawable.fromBitmap(bitmap);
drawable.setBounds(0, 0, thumbSize, thumbSize);
drawable.setCornerRadius(DimensionUnit.DP.toPixels(4));
drawable.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
CharSequence thumbnailSpan = SpanUtil.buildCenteredImageSpan(drawable);
return new SpannableStringBuilder().append(thumbnailSpan).append(bodyWithoutMediaPrefix);
});
}
use of com.bumptech.glide.load.resource.bitmap.CenterCrop in project glide by bumptech.
the class RequestOptionsTest method testApplyMultiTransform.
@Test
@SuppressWarnings({ "unchecked", "varargs" })
public void testApplyMultiTransform() {
options.transforms(new CircleCrop(), new CenterCrop());
assertThat(options.isTransformationRequired()).isTrue();
assertThat(options.getTransformations()).containsKey(Bitmap.class);
assertThat(options.getTransformations().get(Bitmap.class)).isInstanceOf(MultiTransformation.class);
}
Aggregations