Volley框架使用及源码解析
1. Volley特點(diǎn)
(1) 特別適合數(shù)據(jù)量小,通信頻繁的網(wǎng)絡(luò)操作。
(2) 擴(kuò)展性強(qiáng)。Volley 中大多是基于接口的設(shè)計(jì),可根據(jù)需要自行定制。?
(3) 一定程度符合 Http 規(guī)范,包括返回 ResponseCode(2xx、3xx、4xx、5xx)的處理,請(qǐng)求頭的處理, 緩存機(jī)制的支持等。并支持重試及優(yōu)先級(jí)定義。?
(4) 提供簡(jiǎn)便的圖片加載工具
?GitHub地址:https//github.com/mcxiaoke/android-volley
2. 概念介紹
Request:表示一個(gè)請(qǐng)求的抽象類(lèi)。StringRequest、JsonRequest、ImageRequest 都是它的子類(lèi),表示某種類(lèi)型的請(qǐng)求。我們還可以繼承于它,實(shí)現(xiàn)自定義的Request。
RequestQueue:表示請(qǐng)求隊(duì)列,里面包含一個(gè)CacheDispatcher(用于處理緩存請(qǐng)求的線程)、NetworkDispatcher數(shù)組(用于處理網(wǎng)絡(luò)請(qǐng)求的調(diào)度線程,默認(rèn)長(zhǎng)度為4),一個(gè)ResponseDelivery(返回結(jié)果分發(fā))。通過(guò)start() 函數(shù)啟動(dòng)時(shí)會(huì)啟動(dòng)CacheDispatcher和NetworkDispatcher。
CacheDispatcher:一個(gè)線程,用于調(diào)度處理緩存的請(qǐng)求。啟動(dòng)后會(huì)不斷從緩存請(qǐng)求隊(duì)列中取請(qǐng)求處理,隊(duì)列為空則等待,請(qǐng)求處理結(jié)束則將結(jié)果傳遞給ResponseDelivery去執(zhí)行后續(xù)處理。當(dāng)結(jié)果未緩存過(guò)、緩存失效或緩存需要刷新的情況下,該請(qǐng)求都需要重新進(jìn)入NetworkDispatcher去調(diào)度處理。
NetworkDispatcher:一個(gè)線程,用于調(diào)度處理走網(wǎng)絡(luò)的請(qǐng)求。啟動(dòng)后會(huì)不斷從網(wǎng)絡(luò)請(qǐng)求隊(duì)列中取請(qǐng)求處理,隊(duì)列為空則等待,請(qǐng)求處理結(jié)束則將結(jié)果傳遞給ResponseDelivery去執(zhí)行后續(xù)處理,并判斷結(jié)果是否要進(jìn)行緩存。
ResponseDelivery:返回結(jié)果分發(fā)接口,目前只有基于ExecutorDelivery的在傳入的handler對(duì)應(yīng)線程內(nèi)進(jìn)行分發(fā)。
HttpStack:處理 Http 請(qǐng)求,返回請(qǐng)求結(jié)果。目前 Volley 中有基于HttpURLConnection 的HurlStack和 基于 Apache HttpClient 的HttpClientStack。
Network:調(diào)用HttpStack處理請(qǐng)求,并將結(jié)果轉(zhuǎn)換為可被ResponseDelivery處理的NetworkResponse。
Cache:緩存請(qǐng)求結(jié)果,Volley 默認(rèn)使用的是基于 sdcard 的DiskBasedCache。NetworkDispatcher得到請(qǐng)求結(jié)果后判斷是否需要存儲(chǔ)在 Cache,CacheDispatcher會(huì)從 Cache 中取緩存結(jié)果。
?
3. 使用示例
(1) 請(qǐng)求json
RequestQueue mQueue = Volley.newRequestQueue(context);private void getJsonData() {String url=”http://172.17.202.36:8000/data.jason”; JsonObjectRequest jsonRequest = new JsonObjectRequest(url,new Response.Listener<JSONObject>() {@Overridepublic void onResponse(JSONObject response) {Log.d(LOG_TAG, response.toString());}}, new Response.ErrorListener() {@Overridepublic void onErrorResponse(VolleyError error) {Log.e(LOG_TAG, error.getMessage(), error);} }); mQueue.add(jsonRequest); }(2) 請(qǐng)求圖片?
private RequestQueue mQueue = Volley.newRequestQueue(mContext); private ImageLoader mImageLoader = new ImageLoader(mQueue, new BitmapCache());public class BitmapCache implements ImageLoader.ImageCache {private LruCache<String, Bitmap> cache;public BitmapCache() {cache = new LruCache<String, Bitmap>(8 * 1024 * 1024) {@Overrideprotected int sizeOf(String key, Bitmap bitmap) {return bitmap.getRowBytes() * bitmap.getHeight();}};}@Overridepublic Bitmap getBitmap(String url) {return cache.get(url);}@Overridepublic void putBitmap(String url, Bitmap bitmap) {cache.put(url, bitmap);} }private void loadImage() { String imageUrl = “http://172.17.202.36:8000/images/文字_0.png”; ImageView iv = (ImageView)findViewById(R.id.iv); ImageLoader.ImageListener listener = ImageLoader.getImageListener(iv, R.drawable.default_png, R.drawable.error_png); mImageLoader.get(imageUrl, listener); }4. 源碼解析
? ?(1)從使用方式上可以看出,會(huì)先調(diào)用Volley.newRequestQueue(this)獲取到一個(gè)RequestQueue,看下newRequestQueue的內(nèi)容。
public static RequestQueue newRequestQueue(Context context) {return newRequestQueue(context, null);? }public static RequestQueue newRequestQueue(Context context, HttpStack stack)? {return newRequestQueue(context, stack, -1);?}??
public static RequestQueue newRequestQueue(Context context, int maxDiskCacheBytes) {?
return newRequestQueue(context, null, maxDiskCacheBytes);
?}
??/** Default on-disk cache directory. */?
private static final String DEFAULT_CACHE_DIR = "volley";
??public static RequestQueue newRequestQueue(Context context, HttpStack stack, int maxDiskCacheBytes) {
? File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR);
? String userAgent = "volley/0";
? try {?
String packageName = context.getPackageName();?
PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
? userAgent = packageName + "/" + info.versionCode;
? } catch (NameNotFoundException e) {
? }??
if (stack == null) {
? if (Build.VERSION.SDK_INT >= 9) { // API-level >= 9
? stack = new HurlStack();?
} else {? // Prior to Gingerbread, HttpUrlConnection was unreliable.?
stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent));
? }?
}
?? Network network = new BasicNetwork(stack);
?? RequestQueue queue;
? if (maxDiskCacheBytes <= -1)? {?
// No maximum size specified?
queue = new RequestQueue(new DiskBasedCache(cacheDir), network);
? } else {? // Disk cache size specified?
queue = new RequestQueue(new DiskBasedCache(cacheDir, maxDiskCacheBytes), network);
? }
?? queue.start();?
return queue;
?}
RequestQueue的構(gòu)造
/** Number of network request dispatcher threads to start. */?private static final int DEFAULT_NETWORK_THREAD_POOL_SIZE = 4;
??public RequestQueue(Cache cache, Network network) {?
this(cache, network, DEFAULT_NETWORK_THREAD_POOL_SIZE);?
}??
public RequestQueue(Cache cache, Network network, int threadPoolSize) {?
this(cache, network, threadPoolSize, new ExecutorDelivery(new Handler(Looper.getMainLooper())));
?}??
public RequestQueue(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery) {
mCache = cache;
? mNetwork = network;?
mDispatchers = new NetworkDispatcher[threadPoolSize];?
mDelivery = delivery;
?}
mCache : 基于DiskBasedCache的Cache對(duì)象。
mNetwork: 基于BasicNetwork的Network對(duì)象。
mDispatchers: 網(wǎng)絡(luò)請(qǐng)求線程數(shù)組,默認(rèn)大小為4。
mDelivery: 基于ExecutorDelivery的ResponseDelivery對(duì)象,可以看出它Handler的
?? ? ? ? ? ? ? ? ? 線程為主線程。
(2)queue.start()
/**? * Starts the dispatchers in this queue.? */?public void start() {?
stop(); // Make sure any currently running dispatchers are stopped.
? // Create the cache dispatcher and start it.
? mCacheDispatcher = new CacheDispatcher(mCacheQueue, mNetworkQueue, mCache, mDelivery);?
mCacheDispatcher.start();
?? // Create network dispatchers (and corresponding threads) up to the pool size.?
for (int i = 0; i < mDispatchers.length; i++) {?
NetworkDispatcher networkDispatcher = new NetworkDispatcher(mNetworkQueue, mNetwork,? mCache, mDelivery);
? mDispatchers[i] = networkDispatcher;?
networkDispatcher.start();
? }
?}
先quit掉之前的線程,然后創(chuàng)建并啟動(dòng)一個(gè)CacheDispatcher線程和4個(gè)NetworkDispatcher線程。
(3)NetworkDispatcher
public class NetworkDispatcher extends Thread{?...
? public NetworkDispatcher(BlockingQueue<Request<?>> queue,? Network network, Cache cache,? ResponseDelivery delivery) {?
mQueue = queue;?
mNetwork = network;
? mCache = cache;?
mDelivery = delivery;?
}
?? @Override?
public void run() {?
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);?
Request<?> request;?
while (true) {?
long startTimeMs = SystemClock.elapsedRealtime();
? // release previous request object to avoid leaking request object when mQueue is drained.
? request = null;?
try {?
// Take a request from the queue.
? request = mQueue.take();
? } catch (InterruptedException e) {
? // We may have been interrupted because it was time to quit.?
if (mQuit) {?
return;?
}
? continue;?
}??
try {?
request.addMarker("network-queue-take");
?? // If the request was cancelled already, do not perform the network request.?
if (request.isCanceled()) {?
request.finish("network-discard-cancelled");?
continue;
? }
?? addTrafficStatsTag(request);
?? // Perform the network request.?
NetworkResponse networkResponse = mNetwork.performRequest(request);?
request.addMarker("network-http-complete");
?? // If the server returned 304 AND we delivered a response already,? we're done -- don't deliver a second identical response.
? if (networkResponse.notModified && request.hasHadResponseDelivered()) {
? request.finish("not-modified");
? continue;
? }
?? // Parse the response here on the worker thread.?
Response<?> response = request.parseNetworkResponse(networkResponse);
? request.addMarker("network-parse-complete");
?? // Write to cache if applicable.?
// TODO: Only update cache metadata instead of entire record for 304s.?
if (request.shouldCache() && response.cacheEntry != null) {?
mCache.put(request.getCacheKey(), response.cacheEntry);?
request.addMarker("network-cache-written");
? }??
// Post the response back.?
request.markDelivered();
? mDelivery.postResponse(request, response);?
} catch (VolleyError volleyError) {?
......
}
? }?
}
? ......?
}
? 線程的run()方法不斷從mNetworkQueue中取出request, 然后調(diào)用mNetwork.performRequest(request)進(jìn)行網(wǎng)絡(luò)請(qǐng)求,實(shí)際執(zhí)行的是BasicNetwork.performRequest()函數(shù)。在獲取NetworkResponse后,執(zhí)行request.parseNetWorkResponse, 由request進(jìn)行解析,并返回一個(gè)Response<?>對(duì)象。最后執(zhí)行mDelivery.postResponse進(jìn)行結(jié)果分發(fā)。
從這可以看到,自定義的Request必須重寫(xiě)parseNetWorkResponse()這個(gè)函數(shù).
(3)?BasicNetwork.performRequest()的實(shí)現(xiàn)
public class BasicNetwork implements Network {?......
? @Override
? public NetworkResponse performRequest(Request<?> request) throws VolleyError {
? long requestStart = SystemClock.elapsedRealtime();?
while (true) {
? HttpResponse httpResponse = null;
? byte[] responseContents = null;?
Map<String, String> responseHeaders = Collections.emptyMap();?
try {?
// Gather headers.
? Map<String, String> headers = new HashMap<String, String>();?
addCacheHeaders(headers, request.getCacheEntry());
? httpResponse = mHttpStack.performRequest(request, headers);
? StatusLine statusLine = httpResponse.getStatusLine();?
int statusCode = statusLine.getStatusCode();
?? responseHeaders = convertHeaders(httpResponse.getAllHeaders());
? // Handle cache validation.?
if (statusCode == HttpStatus.SC_NOT_MODIFIED) {??
Entry entry = request.getCacheEntry();
? if (entry == null) {
? return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED, null, responseHeaders, true,? SystemClock.elapsedRealtime() - requestStart);
? }
?? entry.responseHeaders.putAll(responseHeaders);?
return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED, entry.data, entry.responseHeaders, true,? SystemClock.elapsedRealtime() - requestStart);?
}
?? // Handle moved resources?
if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {?
String newUrl = responseHeaders.get("Location");
? request.setRedirectUrl(newUrl);
? }??
// Some responses such as 204s do not have content. We must check.?
if (httpResponse.getEntity() != null) {
? responseContents = entityToBytes(httpResponse.getEntity());?
} else {?
// Add 0 byte response as a way of honestly representing a? no-content request.?
responseContents = new byte[0];
? }
?? // if the request is slow, log it.
? long requestLifetime = SystemClock.elapsedRealtime() - requestStart;?
logSlowRequests(requestLifetime, request, responseContents, statusLine);
?? if (statusCode < 200 || statusCode > 299) {
? throw new IOException();
? }
? return new NetworkResponse(statusCode, responseContents, responseHeaders, false,? SystemClock.elapsedRealtime() - requestStart);?
} catch (SocketTimeoutException e) {?
attemptRetryOnException("socket", request, new TimeoutError());?
} catch (ConnectTimeoutException e) {?
attemptRetryOnException("connection", request, new TimeoutError());
? } catch (MalformedURLException e) {?
throw new RuntimeException("Bad URL " + request.getUrl(), e);?
} catch (IOException e) {?
int statusCode = 0;
? NetworkResponse networkResponse = null;?
if (httpResponse != null) {
? statusCode = httpResponse.getStatusLine().getStatusCode();?
} else {?
throw new NoConnectionError(e);
? }?
if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY ||? statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {?
VolleyLog.e("Request at %s has been redirected to %s", request.getOriginUrl(), request.getUrl());
? } else {?
VolleyLog.e("Unexpected response code %d for %s", statusCode, request.getUrl());
? }?
if (responseContents != null) {?
networkResponse = new NetworkResponse(statusCode, responseContents, responseHeaders, false, SystemClock.elapsedRealtime() - requestStart);
? if (statusCode == HttpStatus.SC_UNAUTHORIZED ||? statusCode == HttpStatus.SC_FORBIDDEN) {
? attemptRetryOnException("auth",? request, new AuthFailureError(networkResponse));?
} else if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY ||? statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {?
attemptRetryOnException("redirect",? request, new RedirectError(networkResponse));
? } else {?
// TODO: Only throw ServerError for 5xx status codes.
? throw new ServerError(networkResponse);?
}
? } else {?
throw new NetworkError(e);
? }
? }?
}
? }
? ......
?}
?關(guān)鍵的地方是通過(guò)HttpStack.performRequest()獲取數(shù)據(jù),然后根據(jù)各種情況創(chuàng)建返回不同的NetworkResponse對(duì)象。
(4) CacheDispatcher
public class CacheDispatcher extends Thread {?? private static final boolean DEBUG = VolleyLog.DEBUG;
?? /** The queue of requests coming in for triage. */
? private final BlockingQueue<Request<?>> mCacheQueue;
?? /** The queue of requests going out to the network. */?
private final BlockingQueue<Request<?>> mNetworkQueue;??
/** The cache to read from. */?
private final Cache mCache;
?? /** For posting responses. */?
private final ResponseDelivery mDelivery;
?? /** Used for telling us to die. */?
private volatile boolean mQuit = false;??
public CacheDispatcher(BlockingQueue<Request<?>> cacheQueue, BlockingQueue<Request<?>> networkQueue,? Cache cache, ResponseDelivery delivery) {
? mCacheQueue = cacheQueue;
mNetworkQueue = networkQueue;
? mCache = cache;
? mDelivery = delivery;
? }
?? public void quit() {?
mQuit = true;?
interrupt();
? }
?? @Override
? public void run() {
? if (DEBUG) VolleyLog.v("start new dispatcher");
? Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);??
// Make a blocking call to initialize the cache.?
mCache.initialize();??
Request<?> request;
? while (true) {
? // release previous request object to avoid leaking request object when mQueue is drained.?
request = null;
? try {?
// Take a request from the queue.
? request = mCacheQueue.take();?
} catch (InterruptedException e) {?
// We may have been interrupted because it was time to quit.
? if (mQuit) {?
return;?
}?
continue;?
}?
try {?
request.addMarker("cache-queue-take");??
// If the request has been canceled, don't bother dispatching it.
? if (request.isCanceled()) {
? request.finish("cache-discard-canceled");?
continue;?
}??
// Attempt to retrieve this item from cache.?
Cache.Entry entry = mCache.get(request.getCacheKey());?
if (entry == null) {
? request.addMarker("cache-miss");
? // Cache miss; send off to the network dispatcher.?
mNetworkQueue.put(request);?
continue;?
}
?? // If it is completely expired, just send it to the network.
? if (entry.isExpired()) {?
request.addMarker("cache-hit-expired");
? request.setCacheEntry(entry);
? mNetworkQueue.put(request);
? continue;
? }??
// We have a cache hit; parse its data for delivery back to the request.?
request.addMarker("cache-hit");?
Response<?> response = request.parseNetworkResponse(?new NetworkResponse(entry.data, entry.responseHeaders));?
request.addMarker("cache-hit-parsed");??
if (!entry.refreshNeeded()) {?
// Completely unexpired cache hit. Just deliver the response.?
mDelivery.postResponse(request, response);?
} else {?
// Soft-expired cache hit. We can deliver the cached response,?but we need to also send the request to the network for? refreshing.?
request.addMarker("cache-hit-refresh-needed");?
request.setCacheEntry(entry);
?? // Mark the response as intermediate.
? response.intermediate = true;??
// Post the intermediate response back to the user and have? the delivery then forward the request along to the network.
? final Request<?> finalRequest = request;
? mDelivery.postResponse(request, response, new Runnable() {?
@Override?
public void run() {?
try {
? mNetworkQueue.put(finalRequest);
? } catch (InterruptedException e) {?
// Not much we can do about this.
? }
? }?
});
? }
? } catch (Exception e) {
? VolleyLog.e(e, "Unhandled exception %s", e.toString());
? }?
}
? }
?}
?線程的run()方法不斷從mCacheQueue中取出request, 然后嘗試從mCache中查找request中key(url)對(duì)應(yīng)的entry. 如果entry為空或者過(guò)期,那么直接插入mNetWorkQueue中,由NetworkDispatcher去請(qǐng)求獲取數(shù)據(jù)。如果entry不為空也沒(méi)過(guò)期,那么說(shuō)明可以從mCache中直接獲取,然后進(jìn)行分發(fā)。
(5)?ExecutorDelivery
在創(chuàng)建RequestQueue的時(shí)候,new ExecutorDelivery(new Handler(Looper.getMainLooper()))作為ResponseDelivery實(shí)例。看下ExecutorDelivery的實(shí)現(xiàn)。
?
public class ExecutorDelivery implements ResponseDelivery {? /** Used for posting responses, typically to the main thread. */
? private final Executor mResponsePoster;??
/**? * Creates a new response delivery interface.
? * @param handler {@link Handler} to post responses on?
*/?
public ExecutorDelivery(final Handler handler) {?
// Make an Executor that just wraps the handler.
? mResponsePoster = new Executor() {
? @Override
? public void execute(Runnable command) {?
handler.post(command);
? }
? };?
}
?? /**? * Creates a new response delivery interface, mockable version? * for testing.? * @param executor For running delivery tasks? */
? public ExecutorDelivery(Executor executor) {?
mResponsePoster = executor;?
}
?? @Override?
public void postResponse(Request<?> request, Response<?> response) {?
postResponse(request, response, null);
? }
?? @Override?
public void postResponse(Request<?> request, Response<?> response, Runnable runnable) {
? request.markDelivered();
? request.addMarker("post-response");
? mResponsePoster.execute(new ResponseDeliveryRunnable(request, response, runnable));?
}
?? @Override
? public void postError(Request<?> request, VolleyError error) {?
request.addMarker("post-error");
? Response<?> response = Response.error(error);?
mResponsePoster.execute(new ResponseDeliveryRunnable(request, response, null));
? }
?? /**? * A Runnable used for delivering network responses to a listener on the? main thread.? */?
@SuppressWarnings("rawtypes")
? private class ResponseDeliveryRunnable implements Runnable {?
private final Request mRequest;
? private final Response mResponse;
? private final Runnable mRunnable;??
public ResponseDeliveryRunnable(Request request, Response response, Runnable runnable) {?
mRequest = request;
? mResponse = response;
? mRunnable = runnable;?
}
?? @SuppressWarnings("unchecked")?
@Override
? public void run() {?
// If this request has canceled, finish it and don't deliver.?
if (mRequest.isCanceled()) {?
mRequest.finish("canceled-at-delivery");?
return;
? }
?? // 分發(fā)核心代碼塊
? if (mResponse.isSuccess()) {
? mRequest.deliverResponse(mResponse.result);
? } else {?
mRequest.deliverError(mResponse.error);
? }
?? // If this is an intermediate response, add a marker, otherwise we're done?
// and the request can be finished.?
if (mResponse.intermediate) {?
mRequest.addMarker("intermediate-response");?
} else {?
mRequest.finish("done");?
}??
// If we have been provided a post-delivery runnable, run it.?
if (mRunnable != null) {
? mRunnable.run();
? }?
}
? }?
}
因?yàn)樵跇?gòu)造的時(shí)候傳入了主線程的looper, 所以分發(fā)是直接pose到主線程,可以直接更新UI。在ResponseDeliveryRunnable.run()中調(diào)用request.deliverResponse()分發(fā)response,? 所以自定義的Request還必須重寫(xiě)deliverResponse()。
(5)?RequestQueue.add(request)
/**? * Adds a Request to the dispatch queue.?* @param request The request to service?
* @return The passed-in request? */?
public <T> Request<T> add(Request<T> request) {
? // Tag the request as belonging to this queue and add it to the set of current requests.
? request.setRequestQueue(this);?
synchronized (mCurrentRequests) {?
mCurrentRequests.add(request);?
}
?? // Process requests in the order they are added.
? request.setSequence(getSequenceNumber());?
request.addMarker("add-to-queue");
?? // If the request is uncacheable, skip the cache queue and go straight to the network.
? if (!request.shouldCache()) {
? mNetworkQueue.add(request);?
return request;
? }
?? // Insert request into stage if there's already a request with the same cache key in flight.?
synchronized (mWaitingRequests) {?
String cacheKey = request.getCacheKey();
? if (mWaitingRequests.containsKey(cacheKey)) {
// There is already a request in flight. Queue up.?
Queue<Request<?>> stagedRequests = mWaitingRequests.get(cacheKey);
? if (stagedRequests == null) {?
stagedRequests = new LinkedList<Request<?>>();
? }
? stagedRequests.add(request);
? mWaitingRequests.put(cacheKey, stagedRequests);?
if (VolleyLog.DEBUG) {?
VolleyLog.v("Request for cacheKey=%s is in flight, putting on hold.", cacheKey);?
}?
} else {?
// Insert 'null' queue for this cacheKey, indicating there is now a request in? flight.?
mWaitingRequests.put(cacheKey, null);?
mCacheQueue.add(request);
? }?
return request;
? }
?}
首先將request插入到mCurrentRequests中。如果request不應(yīng)該緩存(默認(rèn)為緩存,通過(guò)調(diào)用Request.setShouldCache(false)改為不緩存),直接插入到mNetworkQueue中。否則,判斷mWaitingRequests中是否含有cacheKey(url), 如果包含,則插入到mWaitingRequests中,不再重復(fù)請(qǐng)求,在上一個(gè)請(qǐng)求返回時(shí)直接發(fā)送結(jié)果;如果不包含cacheKey(url),則插入mWaitingRequests,同時(shí)加入到mCacheQueue中。
轉(zhuǎn)載于:https://www.cnblogs.com/Jackwen/p/5673983.html
總結(jié)
以上是生活随笔為你收集整理的Volley框架使用及源码解析的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Windbg学习 (0x0001) 安装
- 下一篇: java 监听器实现原理