bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.59k stars 6.12k forks source link

Help implementing Pinning images #746

Open TWiStErRob opened 8 years ago

TWiStErRob commented 8 years ago

Update the wiki or create a sample app that does this.

See:

FrancoisBlavoet commented 8 years ago

If you find it satisfactory, you can merge https://github.com/Teovald/glide-wiki/blob/master/Caching-and-Cache-Invalidation.md#dialog-with-another-persistence-layer with Glide's wiki.
I don't think I can make a pull request for the wiki, but you can just merge the diff.

erseno commented 8 years ago

Thanks for this

But regarding

https://gist.github.com/Teovald/bfddf6cbddc8e61ade80

I would like an example of how to register it in a Glide Module and how to use it in a usual Glide request.

FrancoisBlavoet commented 8 years ago

you can use the samples provided by glide in order to get some examples.
For example, the flickr sample shows you how to use a FlickrModelLoader.

erseno commented 8 years ago

Hi Thanks but this is different from the two classes you have provided in the gist above. I want an example on how to use the ASynchronizableDataFetcher and ASynchronizableImageLoader because the description listed in wiki matches my requirements exactly.

TWiStErRob commented 8 years ago

He pointed to those samples because all model loaders needs to be registered the same. Here's a rundown:

ersen-osman commented 8 years ago

•extend both classes found in gist

Hello can you explain this again?, did you mean implement?

At the moment I copied the two classes and created a new class called PieceLoaderbut which class do I extend or implement?

ersen-osman commented 8 years ago
public class PieceLoader extends ASynchronizableDataFetcher<Piece>{

    public PieceLoader(@Nullable DataFetcher<InputStream> networkFetcher, @NonNull Piece piece, int width, int height) {
        super(networkFetcher, piece, width, height);
    }

    @Nullable
    @Override
    public InputStream loadFromSynchro(@NonNull Piece piece, int width, int height) {
        return null;
    }

    @Override
    public String getId() {
        return null;
    }
}

This is what I have so far, I am confused with what I do with ASynchronizableDataFetcher and ASynchronizableImageLoader

TWiStErRob commented 8 years ago

Exactly, that's what I meant by extending. Do the same for the other ASync... class and implement the missing methods as you want.

ersen-osman commented 8 years ago

Thanks. So I make another class called PieceFetcher which will extend ASynchronizableImageLoader?

TWiStErRob commented 8 years ago

Yes, but try to be a little more consistent with naming... ...Fetcher extends A...Fetcher and same for Loader.

ersen-osman commented 8 years ago

Thanks, I got them mixed up :) .

ersen-osman commented 8 years ago

Is there a sample I can refer too? I do not know what to do next :S. The Flickr sample seems different with these two classes. My model already contains URLs and absolute file paths to the image content already.

TWiStErRob commented 8 years ago

I wish I could point to well-rounded sample, that's why this issue exists, to make some clear and easily adaptable sample/docs.

ersen-osman commented 8 years ago

Thanks. I will play around with it and post my findings, if all goes well I can make a sample :)

FrancoisBlavoet commented 8 years ago

IMO, the wiki addition is enough since the rest of the stack is explained either on the wiki or in the samples but I wrote the code so I am obviously biased.

Could you please elaborate on what you are missing Ersen ?

I don't mind writing a 'full' sample if it helps (excluding the implementation of the separate 'pinning' module because that's really up to you).

erseno commented 8 years ago

Hi guys, I hope you had a great Christmas and Happy New Year. I apologise for the late reply. I think a full sample would be great so I decided to start one here to use as a practical example / starting point to demonstrate the usage.

https://github.com/erseno/Glide-Pinning-Image-Sample

However, since I am still trying to find out how it works, I have not written any model loader yet. I prepared a simple app which covers all the mundane things :P

Teovald, I would be extremely grateful if you could fill in the missing implementation and send a pull request.

In the meantime, I will be playing around with this sample to try figure out how to utilise the model loader to achieve what is discussed here. https://github.com/Teovald/glide-wiki/blob/master/Caching-and-Cache-Invalidation.md#dialog-with-another-persistence-layer

Feel free to ask my anything about the sample

FrancoisBlavoet commented 8 years ago

Hi,

happy new year to you too.

I will try to have a look asap, but probably not until this weekend.

erseno commented 8 years ago

Many thanks!

FrancoisBlavoet commented 8 years ago

done. have a look at : https://github.com/Teovald/Glide-Pinning-Image-Sample

Let me know if you need more information.

FrancoisBlavoet commented 8 years ago

I just re-read the wiki article I wrote, I think I will try to clean it up a little bit.

The implementation in the examples is way too detailed for a wiki article.

FrancoisBlavoet commented 8 years ago

done. it should be better now.

erseno commented 8 years ago

Hi Teovald, apologies for the late reply again. Thank you for your contribution :+1:

FrancoisBlavoet commented 8 years ago

You are welcome.

Between the official glide wiki, my additions and the code sample you should have enough information to figure out how this works.
Still, let me know what you think of the doc & the sample.
FWIIW, we have been using similar ModelLoaders/Fetchers on production with several millions daily active users for almost a year, so I am pretty sure that it is solid. :)