博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【深蓝】Volley之Request 2.1
阅读量:6933 次
发布时间:2019-06-27

本文共 1618 字,大约阅读时间需要 5 分钟。

  这次关于的是Request的请求方面。肯定有些整理的不够详细。最后是要规划处Volley的整理框架图出来。

本人经常用的也就是两个请求GET POST 就从这两个请求开始讲起。

 

在Request类的最上方可以看到。

public abstract class Request<T> implements Comparable<Request<T>> 

他是一个抽象类,并且支持Comparable 也就是排序。

先去了解一下,必须要实现的功能是些什么,再了解排序。

1:必须实现的方法。

  1:abstract protected Response<T> parseNetworkResponse(NetworkResponse response); 

      根据Volley作者上面注释:

        

* Subclasses must implement this to parse the raw network response and     * return an appropriate response type. This method will be called from a worker thread. The response will not be delivered if you return null.子类必须实现接信息 没有实现(没有加工的)网络响应和 返回一个适当的响应类型。这个方法将会在一个工作线程被使用。 如果返回为null,这响应将不能在交付.发送

英语差的要命,但是计算机行业必学的一门语言,毕竟美帝的东西比我大中华要先进的好多,这是事实,这里不得吐槽一下了,中国生产硬件,而美国生产软件,软件,,呵呵 这个不用说了。除了人力成本,其他也没什么成本了。为什么小米一个卖手机的价值会这么高?因为MIUI,只是道听途说,如果不对,望纠正。

NetworkResponse 这个类上篇文章已经说明,封装了对应的请求。

Response  这个类是Volley自己定义的。

类注释:Encapsulates a parsed response for delivery.

封装解析响应交付, 在工作线程得到结果,肯定要give to Main Thread(英语一窍不通,必须要强硬头皮去学)

而Response内部直接定义了两个接口

/** Callback interface for delivering parsed responses. */    public interface Listener
{ /** Called when a response is received. */ public void onResponse(T response); }

1注释:回调接口 ,投递解析响应结果。

2注释:响应接收到时调用。

    

/** Callback interface for delivering error responses. */    public interface ErrorListener {        /**         * Callback method that an error has been occurred with the         * provided error code and optional user-readable message.         */        public void onErrorResponse(VolleyError error);    }

 

用过的也就知道,这个事处理解析返回回来错误的结果。

 

 

 

 

 

 

转载于:https://www.cnblogs.com/a-blue/p/3672075.html

你可能感兴趣的文章
Linux学习之CentOS(十二)--crontab命令的使用方法
查看>>
Linux几个命令
查看>>
Linux系统日志级别
查看>>
Web报表工具FineReport中JavaScript的使用
查看>>
EMC virtual provisining and fast vp
查看>>
win10 uwp 如何打包Nuget给其他人
查看>>
活动目录之用户配置文件(转载)
查看>>
Git 远程分支的pull与push
查看>>
mysql单用户赋予多库权限
查看>>
Tcpdump配合Tcpreplay回放实现网络探测
查看>>
mysql多实例安装脚本
查看>>
iOS开发UI篇—UIWindow简单介绍
查看>>
apache+svn服务搭建
查看>>
在一个页面加载另一个渲染的页面
查看>>
linux 历史(histroy)命令记录过滤
查看>>
APACHE 安装出错 configure: error: Cannot use an external APR with the bundled APR-util
查看>>
PHP性能调优,PHP慢日志---PHP脚本执行效率性能检测之WebGrind的使用
查看>>
linux工具之curl与wget高级使用
查看>>
FFmpeg Installation for Ubuntu
查看>>
mysql中表名不区分大小写
查看>>