Search in sources :

Example 1 with RecycledException

use of com.hippo.image.RecycledException in project EhViewer by seven332.

the class LoadImageView method onGetValue.

@Override
public boolean onGetValue(@NonNull ImageBitmap value, int source) {
    Drawable drawable;
    try {
        drawable = new ImageDrawable(value);
    } catch (RecycledException e) {
        // The image might be recycled because it is removed from memory cache.
        Log.d(TAG, "The image is recycled", e);
        return false;
    }
    clearDrawable();
    if (Integer.MIN_VALUE != mOffsetX) {
        drawable = new PreciselyClipDrawable(drawable, mOffsetX, mOffsetY, mClipWidth, mClipHeight);
    }
    onPreSetImageDrawable(drawable, true);
    if ((source == Conaco.SOURCE_DISK || source == Conaco.SOURCE_NETWORK) && isShown()) {
        Drawable[] layers = new Drawable[2];
        layers[0] = new ColorDrawable(Color.TRANSPARENT);
        layers[1] = drawable;
        TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
        setImageDrawable(transitionDrawable);
        transitionDrawable.startTransition(300);
    } else {
        setImageDrawable(drawable);
    }
    return true;
}
Also used : ImageDrawable(com.hippo.image.ImageDrawable) PreciselyClipDrawable(com.hippo.drawable.PreciselyClipDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) RecycledException(com.hippo.image.RecycledException) ColorDrawable(android.graphics.drawable.ColorDrawable) PreciselyClipDrawable(com.hippo.drawable.PreciselyClipDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) ImageDrawable(com.hippo.image.ImageDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable)

Example 2 with RecycledException

use of com.hippo.image.RecycledException in project EhViewer by seven332.

the class UnikeryDrawable method onGetValue.

@Override
public boolean onGetValue(@NonNull ImageBitmap value, int source) {
    ImageDrawable drawable;
    try {
        drawable = new ImageDrawable(value);
    } catch (RecycledException e) {
        Log.d(TAG, "The ImageBitmap is recycled", e);
        return false;
    }
    clearDrawable();
    setDrawable(drawable);
    drawable.start();
    return true;
}
Also used : ImageDrawable(com.hippo.image.ImageDrawable) RecycledException(com.hippo.image.RecycledException)

Aggregations

ImageDrawable (com.hippo.image.ImageDrawable)2 RecycledException (com.hippo.image.RecycledException)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 TransitionDrawable (android.graphics.drawable.TransitionDrawable)1 PreciselyClipDrawable (com.hippo.drawable.PreciselyClipDrawable)1