-
Notifications
You must be signed in to change notification settings - Fork 754
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
RequestQueue.cancelAll doesn't use Object.equals #152
Comments
That's a very good question. Unfortunately it appears to have always been this way, and is even documented as such in the cancelAll() Javadoc, which means it's not something we can change without breaking the API contract. The original change adding this was at https://android.googlesource.com/platform/frameworks/support/+/19a56e8495477bfd89e4c4913860fdbcb7beb504, and even internally I don't see any explanation as to why it was done this way. We can look at adding a new API and deprecating the old one in 1.2.0. In the mean time, it's possibly to specify your own RequestFilter as follows: cancelAll(new RequestFilter() {
@Override
public boolean apply(Request<?> request) {
return Objects.equals(tag, request.getTag());
}
}); |
Of course. I just wanted to point this out :) |
I think it is a intentional designed, RequestManager.cancelAll is a danger method which will to cause all of requests which tag equaled be canceled. use == can be minimize side effect.think this situation has two place request a same url and use a object like a url String |
i agree with @runforprogram, compare '==' with String.equals(), just for efficiency. |
In Request, the tag is defined as an A unit test for this functionality: |
Why shouldn't it use Object.equals?
The text was updated successfully, but these errors were encountered: