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

Reuse old image for Place Holder #688

Closed
thizisarun opened this issue Oct 16, 2015 · 10 comments
Closed

Reuse old image for Place Holder #688

thizisarun opened this issue Oct 16, 2015 · 10 comments
Labels

Comments

@thizisarun
Copy link

I want to reuse the previous version image for place holder how can i achieve this?

@TWiStErRob
Copy link
Collaborator

This is a duplicate of #527 please pick a solution from there.

@thizisarun
Copy link
Author

Hi, It's won't work my scenario . I will explain my scenario , i will add image one by one manually to my gridview in 0'th position. If i am adding a new image at that time it showing previous image only. How can i resolve this here i am enclosed my code

 Glide.with(mImageView.getContext())
    .load(path)
    .listener(new RequestListener<String, GlideDrawable>() {
        @Override public boolean onException(
                Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
            return false;
        }
        @Override public boolean onResourceReady(
                GlideDrawable resource, String model, Target<GlideDrawable> target,
                boolean isFromMemoryCache, boolean isFirstResource) {  // execution order: 2
            target.getSize(new SizeReadyCallback() {
                @Override public void onSizeReady(int width, int height) {  // execution order: 3
                    Glide.with(mImageView.getContext()).load(path).preload(width, height);
                }
            });
            return false;
        }
    })
    .error(R.drawable.broken_img)
    .signature(new StringSignature(mLastModified))
    .dontAnimate()
    .into(mImageView);

@TWiStErRob
Copy link
Collaborator

Adding an item at the beginning of a list shouldn't rebind the rest of the items. It sounds like your getItemId() is not playing nice. Can you please describe in more detail (for example actual behavior and expected behavior) what it is you're trying to achieve?

Is it possible that you're not preloading the correct image? Inside onSizeReady you have path and outside you also have path, in my original code it was pathToLoad2 and pathToLoad. The solution you picked pre-loads the next image causing the next load to hit the memory cache. You can also try the thumbnail solution where the previous(current) image is re-used as a placeholder and the next on is loaded normally.

@thizisarun
Copy link
Author

Ya your are correct at the time i dont have "pathToLoad2 " because i am loading at first time that's why i am giving same path. If i am using above code then i am getting repeated image. Some time it may work correctly

@thizisarun
Copy link
Author

I think glide reuse the particular imageview instance.

@TWiStErRob
Copy link
Collaborator

How about the .signature() there? You need to pass that for every load otherwise you may hit the cache.

@thizisarun
Copy link
Author

i will pause every time based on my object

@TWiStErRob
Copy link
Collaborator

You said you wanted to reuse the old image for placeholder, but now you say that you only have one path?

@thizisarun
Copy link
Author

ya correct path is same but signature is different

@TWiStErRob
Copy link
Collaborator

Then you don't have the future update time, that is the "next path", you'll have to try the thumbnail version from #527. Something like the below should hit the memory/disk cache:

....load(path)
   .signature(currentLastModified)
   .fitCenter()
   .thumbnail(....load(path).signature(previousLastModified).fitCenter())
   .into(mimageView)

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