I have been trying to figure out this issue for two days now and I am completly stumped. For some reason I am sending one request to the queue but volley is returning it twice, which is calling the listener twice and doubling the results in my listview. I turned on the logging for Volley and I can see the request being added to the queue and returned, then a few seconds later the same request is also returned. Log below
V/Volley(14666): [188] CacheDispatcher.run: start new dispatcher
11-15 12:29:30.152: V/Volley(14666): [1] RequestQueue.add: Request for cacheKey=http://reallylongurl is in flight, putting on hold.
11-15 12:29:39.722: V/Volley(14666): [1] RequestQueue.finish: Releasing 1 waiting requests for cacheKey=http://reallylongurl.
11-15 12:29:39.722: D/Volley(14666): [1] MarkerLog.finish: (9809 ms) [ ] http://reallylongurl 0xd68d6603 NORMAL 1
11-15 12:29:39.732: D/Volley(14666): [1] MarkerLog.finish: (+0 ) [ 1] add-to-queue
11-15 12:29:39.732: D/Volley(14666): [1] MarkerLog.finish: (+2169) [188] cache-queue-take
11-15 12:29:39.742: D/Volley(14666): [1] MarkerLog.finish: (+37 ) [188] cache-hit
11-15 12:29:39.742: D/Volley(14666): [1] MarkerLog.finish: (+6878) [188] cache-hit-parsed
11-15 12:29:39.742: D/Volley(14666): [1] MarkerLog.finish: (+0 ) [188] post-response
11-15 12:29:39.752: D/Volley(14666): [1] MarkerLog.finish: (+725 ) [ 1] done
A few other requests get queued here.
11-15 12:29:48.405: D/Volley(14666): [1] MarkerLog.finish: (18302 ms) [ ] http://reallylongurl 0xd68d6603 NORMAL 2
11-15 12:29:48.412: D/Volley(14666): [1] MarkerLog.finish: (+0 ) [ 1] add-to-queue
11-15 12:29:48.412: D/Volley(14666): [1] MarkerLog.finish: (+15164) [188] cache-queue-take
11-15 12:29:48.412: D/Volley(14666): [1] MarkerLog.finish: (+220 ) [188] cache-hit
11-15 12:29:48.432: D/Volley(14666): [1] MarkerLog.finish: (+2299) [188] cache-hit-parsed
11-15 12:29:48.432: D/Volley(14666): [1] MarkerLog.finish: (+0 ) [188] post-response
11-15 12:29:48.442: D/Volley(14666): [1] MarkerLog.finish: (+619 ) [ 1] done
As you can see it never says another request was added nor does it say more then one request was in flight. If I clear out the cache I get the same result, just the first request is from network and the second is returned from cache. I have tried debugging and stepping through my code but I never see the request being enqueued more then once. Has anyone seen this before? Any where else I should look?
Thanks
Edit: Here is the code where I start up volley and where I call it.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState == null) {
TextView emptyView = new TextView(getActivity());
emptyView.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
emptyView.setText("Loading....");
emptyView.setTextSize(20);
emptyView.setGravity(Gravity.CENTER_VERTICAL
| Gravity.CENTER_HORIZONTAL);
((ViewGroup) mListView.getParent()).addView(emptyView);
mListView.setEmptyView(emptyView);
}
mAdapter = new OttoArrayAdapter(mContext);
mListView.setOnScrollListener(onScrollListener);
mListView.setAdapter(mAdapter);
String url = Util.getURL("", mContext);
HttpRequest request = new HttpRequest(url);
request.setTag(mContext);
VolleyLoader.getInstance(mContext).getRequestQueue().add(request);
}
public class VolleyLoader {
private static VolleyLoader mInstance = null;
private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;
private VolleyLoader(Context context) {
OkHttpStack stack = new OkHttpStack();
mRequestQueue = Volley.newRequestQueue(context, stack);
mImageLoader = new ImageLoader(this.mRequestQueue, new LruBitmapCache(
Util.getCacheSize(context)));
}
public static VolleyLoader getInstance(Context context) {
if (mInstance == null) {
mInstance = new VolleyLoader(context);
}
return mInstance;
}
public RequestQueue getRequestQueue() {
return this.mRequestQueue;
}
public ImageLoader getImageLoader() {
return this.mImageLoader;
}
}