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

Pre Download the image and cache it with disklrucache #52

Closed
lalith-b opened this issue Nov 21, 2013 · 11 comments
Closed

Pre Download the image and cache it with disklrucache #52

lalith-b opened this issue Nov 21, 2013 · 11 comments
Labels

Comments

@lalith-b
Copy link

Currently we either need to pass an ImageView and ImageViewTarget both requires imageviews, can`t we just download the image on background without having to display it on UI ?

@shism2
Copy link

shism2 commented Nov 21, 2013

This would be a cool feature to have.

@sjudd
Copy link
Collaborator

sjudd commented Nov 22, 2013

It's actually possible to do this, just implement a nearly empty Target that returns the size of the image you want to download and pass that in as you would an image view or image view target. You can just leave onImageReady blank. This will cause the image to be downloaded and saved to the memory and disk caches.

If you do that, feel free to create a pull request, or even use it to add prefetch() to Glide (in place of into() maybe).

@shism2
Copy link

shism2 commented Dec 27, 2013

Nice job on the preloader.

@tgamez
Copy link

tgamez commented Feb 4, 2014

Is it possible to update de cached version with this request ? Let me explain the situation, we have a current cached version and it's needed to check if it is a new version. The idea is to update it when the new one is loaded without loosing the current image.

@lalith-b
Copy link
Author

great work on the preloader, also can this be worked the other way round as well ? like loading images which are only visible on the listview and cancelling/pausing all other requests. I think its possible if done with volley

        listView.setOnScrollListener(new OnScrollListener(){
            @Override
            public void onScrollStateChanged(AbsListView listView, int scrollState) {
                if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                    mImageLoader.stopProcessingQueue();
                } else {
                    mImageLoader.startProcessingQueue();
                }

@sjudd
Copy link
Collaborator

sjudd commented Mar 31, 2014

Glide does cancel requests for you as you scroll. As long as you reuse views (use convertView in getView of your adapter or add a recycler listener and call Glide.cancel(imageView): http://developer.android.com/reference/android/widget/AbsListView.RecyclerListener.html), Glide will cancel loads for items that are no longer on screen.

@sjudd
Copy link
Collaborator

sjudd commented Jun 28, 2014

Going to close this for now, please reopen if you still need help or have a request!

@sjudd sjudd closed this as completed Jun 28, 2014
@varunmaini
Copy link

Hi, sjudd

Is there any sample code for : "Just implement a nearly empty Target that returns the size of the image you want to download and pass that in as you would an image view or image view target. You can just leave onImageReadyBlank. This will cause the image to be downloaded and saved to the memory and disk caches." ?

I couldn't find any code doing the same in the github repo, please be kind enough to point me to it, if it exists.

Also for such a case will the RequestListener work ?

@TWiStErRob
Copy link
Collaborator

Try SimpleTarget or BaseTarget.

Request listener should still be called as usual.

@sjudd
Copy link
Collaborator

sjudd commented Dec 16, 2014

@varunmaini
Copy link

Thanks TWiStErRob and sjudd. I referred the above sample & SimpleTarget and managed to get a working code snippet. Thanks a lot for the prompt replies.

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

6 participants