Search in sources :

Example 1 with ImageDrawable

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

the class UnikeryDrawable method clearDrawable.

private void clearDrawable() {
    Drawable drawable = getDrawable();
    if (drawable instanceof ImageDrawable) {
        ((ImageDrawable) drawable).recycle();
    }
    setDrawable(null);
}
Also used : ImageDrawable(com.hippo.image.ImageDrawable) ImageDrawable(com.hippo.image.ImageDrawable) Drawable(android.graphics.drawable.Drawable)

Example 2 with ImageDrawable

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

the class LoadImageView method clearDrawable.

private void clearDrawable() {
    // Recycle ImageDrawable
    ImageDrawable imageDrawable = getImageDrawable();
    if (imageDrawable != null) {
        imageDrawable.recycle();
    }
    // Set drawable null
    setImageDrawable(null);
}
Also used : ImageDrawable(com.hippo.image.ImageDrawable)

Example 3 with ImageDrawable

use of com.hippo.image.ImageDrawable 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 4 with ImageDrawable

use of com.hippo.image.ImageDrawable 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)4 Drawable (android.graphics.drawable.Drawable)2 RecycledException (com.hippo.image.RecycledException)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 TransitionDrawable (android.graphics.drawable.TransitionDrawable)1 PreciselyClipDrawable (com.hippo.drawable.PreciselyClipDrawable)1