如果回调凌空请求队列与所有它的任务呢? [英] Callback if Volley RequestQueue is done with all it's tasks?

查看:128
本文介绍了如果回调凌空请求队列与所有它的任务呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的凌空网络库机器人。 得到通知我'寻找一种方式,当一束请求完成,而不是检查所有的响应听众individualy(这也是我做的)。 有一种简单的方式来获得在所有任务都完成的队列中的回调?

I am using the volley networking library for android. I'am looking for a way to get notified when a bunch of requests are finished, rather than checking all the response listeners individualy (which i also do). Is there an easy way to get a callback from the queue when all tasks are done?

推荐答案

请在请求中的一个成员变量和递减计数每次请求结束,并在计数器变为0,你就大功告成了!我不知道暴露一个回调,跟踪所有的请求,回来在最后的。

Keep the requests count in a member variable and decrement everytime a request finishes, and when the counter goes to 0, you're done! I'm not aware of a callback exposed that tracks all the requests and comes back at the end.

int requestPending= 0;
for(int i=0;i<numberOfRequests;i++)
{
    requestQueue.add(request);
    requestPending++;
}
// For each requestQueue item finished onResponse received, do requestPending --

这篇关于如果回调凌空请求队列与所有它的任务呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆