[네이비] Volley Request 2
3790 단어 request
Volley의 요청 대상입니다. Network는 Request를 요청합니다.
Request 구성
public Request(int method, String url, Response.ErrorListener listener) {
mMethod = method;
mUrl = url;
mErrorListener = listener;
setRetryPolicy(new DefaultRetryPolicy());
mDefaultTrafficStatsTag = findDefaultTrafficStatsTag(url);
}
요청 만들기;이것은 요청 방식이 필요합니다:method.GET POST 같은 것들, 그리고 요청한 url.또 하나는리셋에 성공하는 방법을 요청하면listener, 리셋에 실패하는 방법listener가 그를 실행합니다.
여기서 setRetryPolicy () 는 재시도 정책입니다. (여기는 아직 보지 않았습니다. 연결이 성공적으로 재연결되지 않은 것으로 추정됩니다.)
mDefaultTrafficStatsTag은 Url이 비어 있는지 아닌지를 먼저 판단하고 비어 있지 않으면 Uri를 판단합니다.parse(url);ui로 변환할 수 있는지 여부입니다. 변환에 성공하면 ui 문자열을 되돌려줍니다.Hashcode();
그리고 일련의 조작에 따라 이 요청에서network에서 대응하는 정보를 읽습니다.
/**
* Request method of this request. Currently supports GET, POST, PUT,
* DELETE, HEAD, OPTIONS, TRACE, and PATCH.
*/
private final int mMethod;
/** URL of this request. */
private final String mUrl;
/** Default tag for {@link TrafficStats}. */
private final int mDefaultTrafficStatsTag;
/** Listener interface for errors. */
private final Response.ErrorListener mErrorListener;
/** Sequence number of this request, used to enforce FIFO ordering. */
private Integer mSequence;
/** The request queue this request is associated with. */
private RequestQueue mRequestQueue;
/** Whether or not responses to this request should be cached. */
private boolean mShouldCache = true;
/** Whether or not this request has been canceled. */
private boolean mCanceled = false;
/** Whether or not a response has been delivered for this request yet. */
private boolean mResponseDelivered = false;
// A cheap variant of request tracing used to dump slow requests.
private long mRequestBirthTime = 0;
/**
* Threshold at which we should log the request (even when debug logging is
* not enabled).
*/
private static final long SLOW_REQUEST_THRESHOLD_MS = 3000;
/** The retry policy for this request. */
private RetryPolicy mRetryPolicy;
/**
* When a request can be retrieved from cache but must be refreshed from the
* network, the cache entry will be stored here so that in the event of a
* "Not Modified" response, we can be sure it hasn't been evicted from
* cache.
*/
private Cache.Entry mCacheEntry = null;
/** An opaque token tagging this request; used for bulk cancellation. */
private Object mTag;