Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
之前是必须在网络请求之前添加好所有的listener,但是有些场景需要在网络请求之后还可以添加新的listener。
比如常见的应用市场,app列表页面每一个item会有一个下载按钮,点击后开始下载并显示进度,而点击item进入详情页也会有一个带进度的下载按钮,如果先在列表页面点击了下载,再进入详情页,详情页也应该和列表页同步地获取到进度信息。
主要改动是ProgressRequestBody和ProgressResponseBody中的mListeners由数组改为List,与ProgressManager中的listener指向相同的内存地址,同时构造函数中的listeners也不再有null的情况,在ProgressManager的wrap方法中,如果根据url获取到的listeners为null,会put进去一个空的List并传给ProgressRequestBody/ProgressResponseBody。