square / picasso

A powerful image downloading and caching library for Android
https://square.github.io/picasso/
Apache License 2.0
18.71k stars 3.97k forks source link

Support pluggable asynchronous image loading. #1397

Open code-beans opened 8 years ago

code-beans commented 8 years ago

So in my project I have a listview with icons. I integrated the unity game engine in my project which will render icons and return an encoded png in form of a byte array.

I have a bridge between android and the unity side. In essence it accepts a static call via public static void GetIcon(OnImageReceived onImageReceived,JSONObject json) {..}

with the callback having this signature

public interface OnImageReceived {

    public void ImageReceived(byte[] bytes);

}

the json just holds additional render info specific to that icon being rendered. The callback will be invoked 40ms later or a second later or worst case never. So how do I make picasso load these icons properly and meanwhile show a placeholder image? I tried to follow this example using a custom downloader but couldn't really get things up an running. Then I tried to follow this issue but all links are pretty much dead. So can you point me in the right direction? Do I need a custom downloader or taget?

I am using a custom adapter and load the image into an ImageView in the getView(int position, View view, ViewGroup parent) method of the adapter. Ideally I would like to cache the icons in the cache folder of the internal storage using a hash of that json.

Thanks

JakeWharton commented 8 years ago

We have no way to asynchronously load an image at this time. Downloaders are required to be synchronous for now.

This is something we potentially can address is a version 3.

NightlyNexus commented 6 years ago

Open to contributions for this?

JakeWharton commented 6 years ago

Yes

JakeWharton commented 6 years ago

We need to make pluggable bitmap/drawable factories async to support OkHttp's enqueue API. But I'd also like to support pushing multiple instances through the async pipeline to handle things like progressive jpg. Going to dupe a request for that onto this.

NightlyNexus commented 6 years ago

I have not caught up on all the context yet, but multiple instances of what?

JakeWharton commented 6 years ago

images

On Sat, Mar 3, 2018 at 12:53 AM Eric Cochran notifications@github.com wrote:

I have not caught up on all the context yet, but multiple instances of what?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/square/picasso/issues/1397#issuecomment-370121851, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEVoJ9LURWhpF4QXBBzA6CSpFZ-lHks5tai_rgaJpZM4Im3Kx .