use of com.zzhoujay.richtext.drawable.DrawableWrapper in project RichText by zzhoujay.
the class ImageTargetBitmap method onResourceReady.
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
if (!activityIsAlive()) {
return;
}
DrawableWrapper drawableWrapper = urlDrawableWeakReference.get();
if (drawableWrapper == null) {
return;
}
TextView textView = textViewWeakReference.get();
holder.setImageState(ImageHolder.ImageState.READY);
holder.setSize(resource.getWidth(), resource.getHeight());
Drawable drawable = new BitmapDrawable(textView.getContext().getResources(), resource);
drawableWrapper.setDrawable(drawable);
if (holder.getCachedBound() != null) {
drawableWrapper.setBounds(holder.getCachedBound());
} else {
if (!config.autoFix && config.imageFixCallback != null) {
config.imageFixCallback.onImageReady(holder, resource.getWidth(), resource.getHeight());
}
if (config.autoFix || holder.isAutoFix() || !holder.isInvalidateSize()) {
int width = getRealWidth();
int height = (int) ((float) resource.getHeight() * width / resource.getWidth());
drawableWrapper.setBounds(0, 0, width, height);
} else {
drawableWrapper.setBounds(0, 0, (int) holder.getScaleWidth(), (int) holder.getScaleHeight());
}
}
resetText();
loadDone();
}
Aggregations