这似乎是一个愚蠢的问题,但我无法理解 AsynctaskLoader 的状态。
我已多次阅读文档以及网络上的其他教程。但是,我仍然无法理解 Asynctask 何时处于重置状态
看一下从官方文档中提取的这段代码。 http://developer.android.com/reference/android/content/AsyncTaskLoader.html
@Override public void deliverResult(List<AppEntry> apps) {
if (isReset()) {
// An async query came in while the loader is stopped. We
// don't need the result.
if (apps != null) {
onReleaseResources(apps);
}
}
Run Code Online (Sandbox Code Playgroud)
调用此方法后 Loader 完成其工作并需要将数据发送回 UI 线程。我的问题是:为什么我们要问 Loader 是否重置?重置它甚至意味着什么?班级说
/**
* Return whether this load has been reset. That is, either the loader
* has not yet been started for the first time, or its {@link #reset()}
* has been called.
*/
Run Code Online (Sandbox Code Playgroud)
你会认为如果加载程序没有第一次启动,它会在 STOPPED 声明中,为什么重新启动?。
我想我并没有真正理解 Loader 如何对 Activity Lifecycle 做出反应,但文档对此一无所知。
| 归档时间: |
|
| 查看次数: |
953 次 |
| 最近记录: |