Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change DecodeFormat on a per request basis ? #405

Closed
Tolriq opened this issue Apr 13, 2015 · 6 comments
Closed

Change DecodeFormat on a per request basis ? #405

Tolriq opened this issue Apr 13, 2015 · 6 comments
Labels

Comments

@Tolriq
Copy link
Contributor

Tolriq commented Apr 13, 2015

Forget to post that earlier, but it seems that there's no way to change DecodeFormat on a per request basis.

Only at glide level.

Is there a way via a specific model loader or something to have different configuration for this ?

I do no need transparency for 95% of the requests and default configuration is perfect but for the 5 last percent (known cases) I need it and activating it for everything is a huge waste of resources :(

@sjudd
Copy link
Collaborator

sjudd commented Apr 13, 2015

@sjudd sjudd added the question label Apr 13, 2015
@Tolriq
Copy link
Contributor Author

Tolriq commented Apr 14, 2015

Hum, ok did not find this one :(

This removes the crossFade from builder so I suppose that I have to use the animate functions but then how to I access the previous image to do the cross fade ?

This also show another thing from the doc animate is not applied when image is loaded from memory, but crossfade documentation does not talk about this same limitation.

Is crossfade always applied or documentation just miss this information ?

@sjudd
Copy link
Collaborator

sjudd commented Apr 14, 2015

CrossFade uses Android's TransitionDrawable which expects Drawables, not Bitmaps. As a result, crossFade doesn't work out of the box with asBitmap(). I believe asBitmap() defaults to fading the view in instead.

If you need to both set the format on a per request basis and use cross fade, you can do one of two things:

  1. Look at the code for .format() in BitmapRequestBuilder and apply the same pattern as a decoder and cache decoder for DrawableRequestBuilder (it's just a lot of wrapping decoders...).
  2. Continue to use asBitmap(), but create a custom ImageViewTarget subclass that accepts a Bitmap, puts it into a BitmapDrawable, and then sets a TransitionDrawable on the view.

If it were me, I'd be inclined toward 2, but either one should work.

@Tolriq
Copy link
Contributor Author

Tolriq commented Apr 14, 2015

Well since it's only a very small subset of my app, I suppose I'll go with simple animation and no place holder as data should be available quickly.

Before closing this one can you confirm that either the crossfade apply even when loaded from memory or that the placeholder will not be displayed before if loaded from memory ?

@sjudd
Copy link
Collaborator

sjudd commented Apr 14, 2015

Neither animations nor placeholders are applied when loading resources from the memory cache.

@Tolriq
Copy link
Contributor Author

Tolriq commented Apr 14, 2015

Ok thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants