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

[SDWebImage] #541

Closed
wants to merge 1 commit into from
Closed

[SDWebImage] #541

wants to merge 1 commit into from

Conversation

leverdeterre
Copy link

Try to use an the previous cached image for placeholder

	Try to use an the previous cached image for placeholder
@bpoplauschi
Copy link
Member

@leverdeterre could you please rebase this on top of master, so it's mergeable?

@Whirlwind
Copy link
Contributor

I think it is not good idea.

The better way is that like setImageURL:placeHolderImage:UsingCache:. It like to request the network, and it will use cache if failed and the cache exists.

bpoplauschi added a commit that referenced this pull request Jun 25, 2014
@bpoplauschi
Copy link
Member

Replaced by 30f6726

@dreampiggy
Copy link
Contributor

dreampiggy commented Jan 14, 2018

This API should be deprecated and it's not a good design.

Maybe your use case is that: if the memory or disk cache contains the image, show that instead of placeholder! else, firstly show the placeholder, then download from the network and replace the placeholder!. But this can be done by Core Animation's composition without this strange API.

If we can ensure all the process happend during the same runloop, even if you provide a placeholder and call imageView.image = placeholder
and then we query the cache synchronously, call imageView.image = image,
the actually rendering will only show the last image because the previous setImage will be ignored by Core Animation.

Of couse, if memory & disk cache missed. The placeholder will be rendering, and the network start, once finished, the imageView will trigger imageView.image = networkImage.

So, I think, all you need to do, it's a SDWebImageOptions for hint that the cache query should be synchronously, but not such a strange API. SD 4.3 introduce SDImageCacheQueryDiskSync and so this can be done easily. The current API will be marked deprecated and removed in 5.x.

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

Successfully merging this pull request may close these issues.

5 participants