use of com.bumptech.glide.load.resource.drawable.GlideDrawable in project Reader by TheKeeperOfPie.
the class ImageViewZoom method setImageDrawable.
@Override
public void setImageDrawable(final Drawable drawable) {
if (drawable instanceof BitmapDrawable || drawable instanceof GlideDrawable) {
contentWidth = drawable.getIntrinsicWidth();
contentHeight = drawable.getIntrinsicHeight();
UtilsImage.checkMaxTextureSize(getHandler(), () -> {
if (contentWidth > UtilsImage.getMaxTextureSize() || contentHeight > UtilsImage.getMaxTextureSize()) {
listener.onTextureSizeExceeded();
return;
}
int startHeight = 0;
int targetHeight = (int) (getWidth() * contentHeight / contentWidth);
listener.onBeforeContentLoad(getWidth(), targetHeight);
setScaleType(ScaleType.MATRIX);
ImageViewZoom.super.setImageDrawable(drawable);
scaleStart = getWidth() / contentWidth;
translationX = (scaleCurrent - 1) * contentWidth / 2;
translationY = (scaleCurrent - 1) * contentHeight / 2;
setScaleFactor(0, 0, scaleStart);
if (getParent() instanceof View) {
startHeight = ((View) getParent()).getHeight();
}
ValueAnimator valueAnimator = ValueAnimator.ofInt(startHeight, targetHeight);
valueAnimator.addUpdateListener(animation -> {
getLayoutParams().height = (int) animation.getAnimatedValue();
requestLayout();
});
valueAnimator.start();
});
} else {
super.setImageDrawable(drawable);
}
}
Aggregations