use of org.telegram.ui.Components.RecyclableDrawable in project Telegram-FOSS by Telegram-FOSS-Team.
the class ImageReceiver method setImageBitmap.
public void setImageBitmap(Drawable bitmap) {
ImageLoader.getInstance().cancelLoadingForImageReceiver(this, true);
if (crossfadeWithOldImage) {
if (currentImageDrawable != null) {
recycleBitmap(null, TYPE_THUMB);
recycleBitmap(null, TYPE_CROSSFDADE);
recycleBitmap(null, TYPE_MEDIA);
crossfadeShader = imageShader;
crossfadeImage = currentImageDrawable;
crossfadeKey = currentImageKey;
crossfadingWithThumb = true;
} else if (currentThumbDrawable != null) {
recycleBitmap(null, TYPE_IMAGE);
recycleBitmap(null, TYPE_CROSSFDADE);
recycleBitmap(null, TYPE_MEDIA);
crossfadeShader = thumbShader;
crossfadeImage = currentThumbDrawable;
crossfadeKey = currentThumbKey;
crossfadingWithThumb = true;
} else if (staticThumbDrawable != null) {
recycleBitmap(null, TYPE_IMAGE);
recycleBitmap(null, TYPE_THUMB);
recycleBitmap(null, TYPE_CROSSFDADE);
recycleBitmap(null, TYPE_MEDIA);
crossfadeShader = thumbShader;
crossfadeImage = staticThumbDrawable;
crossfadingWithThumb = true;
crossfadeKey = null;
} else {
for (int a = 0; a < 4; a++) {
recycleBitmap(null, a);
}
crossfadeShader = null;
}
} else {
for (int a = 0; a < 4; a++) {
recycleBitmap(null, a);
}
}
if (staticThumbDrawable instanceof RecyclableDrawable) {
RecyclableDrawable drawable = (RecyclableDrawable) staticThumbDrawable;
drawable.recycle();
}
if (bitmap instanceof AnimatedFileDrawable) {
AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) bitmap;
fileDrawable.setParentView(parentView);
if (attachedToWindow) {
fileDrawable.addParent(parentView);
}
fileDrawable.setUseSharedQueue(useSharedAnimationQueue || fileDrawable.isWebmSticker);
if (allowStartAnimation && currentOpenedLayerFlags == 0) {
fileDrawable.start();
}
fileDrawable.setAllowDecodeSingleFrame(allowDecodeSingleFrame);
} else if (bitmap instanceof RLottieDrawable) {
RLottieDrawable fileDrawable = (RLottieDrawable) bitmap;
fileDrawable.addParentView(parentView);
if (allowStartLottieAnimation && (!fileDrawable.isHeavyDrawable() || currentOpenedLayerFlags == 0)) {
fileDrawable.start();
}
fileDrawable.setAllowDecodeSingleFrame(true);
}
thumbShader = null;
roundPaint.setShader(null);
staticThumbDrawable = bitmap;
updateDrawableRadius(bitmap);
currentMediaLocation = null;
currentMediaFilter = null;
currentMediaDrawable = null;
currentMediaKey = null;
mediaShader = null;
currentImageLocation = null;
currentImageFilter = null;
currentImageDrawable = null;
currentImageKey = null;
imageShader = null;
composeShader = null;
legacyShader = null;
legacyCanvas = null;
if (legacyBitmap != null) {
legacyBitmap.recycle();
legacyBitmap = null;
}
currentThumbLocation = null;
currentThumbFilter = null;
currentThumbKey = null;
currentKeyQuality = false;
currentExt = null;
currentSize = 0;
currentCacheType = 0;
currentAlpha = 1;
previousAlpha = 1f;
if (setImageBackup != null) {
setImageBackup.clear();
}
if (delegate != null) {
delegate.didSetImage(this, currentThumbDrawable != null || staticThumbDrawable != null, true, false);
}
if (parentView != null) {
if (invalidateAll) {
parentView.invalidate();
} else {
parentView.invalidate((int) imageX, (int) imageY, (int) (imageX + imageW), (int) (imageY + imageH));
}
}
if (forceCrossfade && crossfadeWithOldImage && crossfadeImage != null) {
currentAlpha = 0.0f;
lastUpdateAlphaTime = System.currentTimeMillis();
crossfadeWithThumb = currentThumbDrawable != null || staticThumbDrawable != null;
}
}
Aggregations