我现在用的凌空网络库机器人。 得到通知我'寻找一种方式,当一束请求完成,而不是检查所有的响应听众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 --