Search in sources :

Example 1 with PreciselyClipDrawable

use of com.hippo.drawable.PreciselyClipDrawable 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)

Aggregations

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