[关闭]
@946898963 2018-05-18T11:28:48.000000Z 字数 741 阅读 1035

Volley-Response源码解析

Android控件跟框架 Android源码分析


  1. public class Response<T> {
  2. public interface Listener<T> {
  3. public void onResponse(T response);
  4. }
  5. public interface ErrorListener {
  6. public void onErrorResponse(VolleyError error);
  7. }
  8. public final T result;
  9. public final Cache.Entry cacheEntry;
  10. public final VolleyError error;
  11. public boolean intermediate = false;
  12. public boolean isSuccess() {
  13. return error == null;
  14. }
  15. private Response(T result, Cache.Entry cacheEntry) {
  16. this.result = result;
  17. this.cacheEntry = cacheEntry;
  18. this.error = null;
  19. }
  20. private Response(VolleyError error) {
  21. this.result = null;
  22. this.cacheEntry = null;
  23. this.error = error;
  24. }
  25. public static <T> Response<T> success(T result, Cache.Entry cacheEntry) {
  26. return new Response<T>(result, cacheEntry);
  27. }
  28. public static <T> Response<T> error(VolleyError error) {
  29. return new Response<T>(error);
  30. }
  31. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注