Implement request group and pause/resume support#665
Implement request group and pause/resume support#665JakeWharton merged 2 commits intosquare:masterfrom lucasr:request-group
Conversation
There was a problem hiding this comment.
No settling state :( Damn you, AbsListView.
|
Updated the branch:
|
There was a problem hiding this comment.
Small nitpick: Should be "that must be managed"
|
This is awesome and a great example why I love OSS. I am curious about the performance gains from this change. I've always thought the sample app had good performance and near 60fps but everynow and then it would skip a frame. I think this will eliminate this. |
|
What do you think about naming this "tag" for parity with OkHttp and Volley (and eventually maybe Retrofit)? |
|
@JakeWharton I'm fine with "tag". I started with it but thought the notion of "request groups" sounded cooler :-) Method names looked a bit verbose though e.g. |
|
Maybe just |
|
Updated branch:
|
|
I was going to say we could just do |
|
@JakeWharton Good point. Done. |
|
Updated branch:
FWIW, I'm happy with the state of the branch now. The only open question I can think of is whether or not we want to have APIs to cancel/pause/resume all requests. We can do this in a follow-up ticket after merging this PR though. Thoughts? |
|
Also, maybe add this PR to the 2.4 milestone and close #561? |
|
We don't really use milestones much. Just when were planning issues for the
|
There was a problem hiding this comment.
I will never use strings so let's not say most.
|
This looks fantastic. Beers will reign down upon you the next time you come to SF. Thanks for putting up with our sometimes ridiculous nit picking. |
|
Branch updated with all suggested changes. |
There was a problem hiding this comment.
I think we want to reuse the "Paused" verb here. "Ignored" makes it seem like we aren't deferring the request.
|
Sorry one more tiny, tiny thing. LGTM otherwise! |
|
@JakeWharton Branch updated. |
|
You need to rebase, but only because I merged your other awesome PR. |
|
Rebased. |
Implement request group and pause/resume support
|
Thanks! |
|
\o/ |
|
When can we expect a release? |
|
We don't provide ETAs. We'll release when we feel that it's been thoroughly tested and stable. |
|
This is awesome. Big kudos! |
Ok, here's an initial take on the whole pause/resume support for Picasso.
This PR adds a new API to
RequestCreatorthat allows you set a group tag/marker to specific requests:By default, all requests are associated with the default group defined as
Picasso.DEFAULT_GROUP. This tag can be used to cancel, pause, and resume requests in the same group. To do so, you can use the following new APIs inPicasso:cancelRequestGroup(String group)pauseRequestGroup(String group)resumeRequestGroup(String group)Maybe we should also have
pauseRequest(Target|ImageView|RemoveView)andresumeRequest(Target|ImageView|RemoveView)for parity with the existingcancelRequest(Target|ImageView|RemoveView). Let me know what you think.Here are a few general notes on how this new API behaves:
BitmapHunteruntil the group gets resumed. In this case, the requests for a paused group will be queued in theDispatcher(seepausedActionsmember).BitmapHunteris either running or waiting for its turn), the requests in the now paused group will get detached from any pendingBitmapHunterimmediately. If the affectedBitmapHunterends up with no pending actions, it will get canceled (seeperformPauseGroup).performCancel). This might happen, for example, if a new request is initiated for the same target than a paused request.BitmapHuntermight containActionsfrom multiple groups at any given time. Not likely to happen in practice, but it's something we have to handle. This is why there's no 1-to-1 mapping betweenBitmapHunterand requests groups.I should probably add some more tests for the new APIs. But I wanted to get some early feedback before spending more time on them. I've added a super simple scroll listener based on the new API. Works like a charm ;-)
closes #561