Reputation: 2856
I am assigning the tag to OkHttp Request like,
Request request = new Request.Builder()
.url(url)
.tag(requestTag)
.build();
and I can cancel that particular request by that using
public static void cancel(Object tag) {
for (Call call : getClient().dispatcher().queuedCalls()) {
if (tag.equals(call.request().tag())) call.cancel();
}
for (Call call : getClient().dispatcher().runningCalls()) {
if (tag.equals(call.request().tag())) call.cancel();
}
}
But how to assign multiple tag to request because I have to track the request and if any request has timeout then I have to cancel the related tag request
Any idea?
Upvotes: 2
Views: 1975
Reputation: 40587
Change your application to always use a Set
for its tags. In your canceling code you’ll need to downcast.
Upvotes: 1