Search in sources :

Example 1 with HookImage

use of com.eros.framework.extend.hook.ui.components.HookImage in project WeexErosFramework by bmfe.

the class DefaultWXImageAdapter method handleError.

private void handleError(HookWXImageView imageView) {
    HookImage component = imageView.getComponent();
    if (component == null)
        return;
    ImmutableDomObject domObject = component.getDomObject();
    if (domObject == null)
        return;
    Bitmap bitmap = getErrorBitmap(imageView.getContext());
    if (domObject.getLayoutWidth() > 0 && domObject.getLayoutHeight() > 0) {
        int target = Math.min((int) (domObject.getLayoutWidth()), (int) (domObject.getLayoutHeight())) / 2;
        Bitmap zoomBitmap = ImageUtil.zoomImage(bitmap, target, target);
        if (zoomBitmap != null) {
            imageView.drawErrorBitmap(zoomBitmap);
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) ImmutableDomObject(com.taobao.weex.dom.ImmutableDomObject) HookImage(com.eros.framework.extend.hook.ui.components.HookImage)

Example 2 with HookImage

use of com.eros.framework.extend.hook.ui.components.HookImage in project WeexErosFramework by bmfe.

the class HookWXImageView method autoReleaseImage.

public void autoReleaseImage() {
    if (enableBitmapAutoManage) {
        if (!isBitmapReleased) {
            isBitmapReleased = true;
            HookImage image = getComponent();
            if (image != null) {
                image.autoReleaseImage();
            }
        }
    }
}
Also used : HookImage(com.eros.framework.extend.hook.ui.components.HookImage)

Example 3 with HookImage

use of com.eros.framework.extend.hook.ui.components.HookImage in project WeexErosFramework by bmfe.

the class HookWXImageView method setImageDrawable.

public void setImageDrawable(@Nullable Drawable drawable, boolean isGif) {
    this.gif = isGif;
    ViewGroup.LayoutParams layoutParams;
    if ((layoutParams = getLayoutParams()) != null) {
        Drawable wrapDrawable = ImageDrawable.createImageDrawable(drawable, getScaleType(), borderRadius, layoutParams.width - getPaddingLeft() - getPaddingRight(), layoutParams.height - getPaddingTop() - getPaddingBottom(), isGif);
        if (wrapDrawable instanceof ImageDrawable) {
            ImageDrawable imageDrawable = (ImageDrawable) wrapDrawable;
            if (!Arrays.equals(imageDrawable.getCornerRadii(), borderRadius)) {
                imageDrawable.setCornerRadii(borderRadius);
            }
        }
        if (wrapDrawable instanceof GifDrawable) {
            if (mGifBorderRadius == null) {
                mGifBorderRadius = new float[] { 0, 0, 0, 0, 0, 0, 0, 0 };
            }
            if (!Arrays.equals(borderRadius, mGifBorderRadius)) {
                mGifBorderRadius = borderRadius;
                setGifCornerRadii((GifDrawable) wrapDrawable);
            }
        }
        super.setImageDrawable(wrapDrawable);
        if (mWeakReference != null) {
            HookImage component = mWeakReference.get();
            if (component != null) {
                component.readyToRender();
            }
        }
    }
}
Also used : ImageDrawable(com.taobao.weex.utils.ImageDrawable) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageDrawable(com.taobao.weex.utils.ImageDrawable) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable) HookImage(com.eros.framework.extend.hook.ui.components.HookImage)

Example 4 with HookImage

use of com.eros.framework.extend.hook.ui.components.HookImage in project WeexErosFramework by bmfe.

the class HookWXImageView method autoRecoverImage.

public void autoRecoverImage() {
    if (enableBitmapAutoManage) {
        if (isBitmapReleased) {
            HookImage image = getComponent();
            if (image != null) {
                image.autoRecoverImage();
            }
            isBitmapReleased = false;
        }
    }
}
Also used : HookImage(com.eros.framework.extend.hook.ui.components.HookImage)

Aggregations

HookImage (com.eros.framework.extend.hook.ui.components.HookImage)4 Bitmap (android.graphics.Bitmap)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Drawable (android.graphics.drawable.Drawable)1 ViewGroup (android.view.ViewGroup)1 GifDrawable (com.bumptech.glide.load.resource.gif.GifDrawable)1 ImmutableDomObject (com.taobao.weex.dom.ImmutableDomObject)1 ImageDrawable (com.taobao.weex.utils.ImageDrawable)1