Search in sources :

Example 1 with GlideBitmapDrawable

use of com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable in project plaid by nickbutcher.

the class DribbbleTarget method onResourceReady.

@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
    super.onResourceReady(resource, animation);
    if (!autoplayGifs) {
        resource.stop();
    }
    BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView();
    if (resource instanceof GlideBitmapDrawable) {
        Palette.from(((GlideBitmapDrawable) resource).getBitmap()).clearFilters().generate(this);
    } else if (resource instanceof GifDrawable) {
        Bitmap image = ((GifDrawable) resource).getFirstFrame();
        Palette.from(image).clearFilters().generate(this);
        // look at the corner to determine the gif badge color
        int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics().scaledDensity);
        Bitmap corner = Bitmap.createBitmap(image, image.getWidth() - cornerSize, image.getHeight() - cornerSize, cornerSize, cornerSize);
        boolean isDark = ColorUtils.isDark(corner);
        corner.recycle();
        badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(), isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image));
    }
}
Also used : BadgedFourThreeImageView(io.plaidapp.ui.widget.BadgedFourThreeImageView) Bitmap(android.graphics.Bitmap) GlideBitmapDrawable(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable)

Example 2 with GlideBitmapDrawable

use of com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable in project Shuttle by timusus.

the class GlidePalette method onResourceReady.

@Override
public boolean onResourceReady(TranscodeType resource, ModelType model, Target<TranscodeType> target, boolean isFromMemoryCache, boolean isFirstResource) {
    boolean callbackResult = this.callback != null && this.callback.onResourceReady(resource, model, target, isFromMemoryCache, isFirstResource);
    Bitmap b = null;
    if (resource instanceof Bitmap) {
        b = (Bitmap) resource;
    } else if (resource instanceof GlideBitmapDrawable) {
        b = ((GlideBitmapDrawable) resource).getBitmap();
    } else if (target instanceof BitmapHolder) {
        b = ((BitmapHolder) target).getBitmap();
    }
    if (b != null) {
        start(b);
    }
    return callbackResult;
}
Also used : Bitmap(android.graphics.Bitmap) GlideBitmapDrawable(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable)

Example 3 with GlideBitmapDrawable

use of com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable in project LookLook by xinghongfei.

the class DribbbleTarget method onResourceReady.

@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
    super.onResourceReady(resource, animation);
    if (!autoplayGifs) {
        resource.stop();
    }
    BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView();
    if (resource instanceof GlideBitmapDrawable) {
        Palette.from(((GlideBitmapDrawable) resource).getBitmap()).clearFilters().generate(this);
    } else if (resource instanceof GifDrawable) {
        Bitmap image = ((GifDrawable) resource).getFirstFrame();
        Palette.from(image).clearFilters().generate(this);
        // look at the corner to determine the gif badge color
        int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics().scaledDensity);
        Bitmap corner = Bitmap.createBitmap(image, image.getWidth() - cornerSize, image.getHeight() - cornerSize, cornerSize, cornerSize);
        boolean isDark = ColorUtils.isDark(corner);
        corner.recycle();
        badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(), isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image));
    }
}
Also used : BadgedFourThreeImageView(com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView) Bitmap(android.graphics.Bitmap) GlideBitmapDrawable(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable)

Example 4 with GlideBitmapDrawable

use of com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable in project LookLook by xinghongfei.

the class ImageTarget method onResourceReady.

@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
    super.onResourceReady(resource, animation);
    if (!autoplayGifs) {
        resource.stop();
    }
    BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView();
    if (resource instanceof GlideBitmapDrawable) {
        Palette.from(((GlideBitmapDrawable) resource).getBitmap()).clearFilters().generate(this);
    } else if (resource instanceof GifDrawable) {
        Bitmap image = ((GifDrawable) resource).getFirstFrame();
        Palette.from(image).clearFilters().generate(this);
        // look at the corner to determine the gif badge color
        int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics().scaledDensity);
        Bitmap corner = Bitmap.createBitmap(image, image.getWidth() - cornerSize, image.getHeight() - cornerSize, cornerSize, cornerSize);
        boolean isDark = ColorUtils.isDark(corner);
        corner.recycle();
        badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(), isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image));
    }
}
Also used : BadgedFourThreeImageView(com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView) Bitmap(android.graphics.Bitmap) GlideBitmapDrawable(com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable)

Aggregations

Bitmap (android.graphics.Bitmap)4 GlideBitmapDrawable (com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable)4 GifDrawable (com.bumptech.glide.load.resource.gif.GifDrawable)3 BadgedFourThreeImageView (com.looklook.xinghongfei.looklook.widget.BadgedFourThreeImageView)2 BadgedFourThreeImageView (io.plaidapp.ui.widget.BadgedFourThreeImageView)1