public abstract class AsyncTaskLoader
extends Loader<D>
| java.lang.Object | ||
| android.support.v4.content.Loader<D> | ||
| android.support.v4.content.AsyncTaskLoader<D> | ||
| |
静态库支持版本的框架AsyncTaskLoader 。 用于编写在Android 3.0之前的平台上运行的应用程序。 在Android 3.0或更高版本上运行时,此实现仍在使用; 它不会尝试切换到框架的实现。 请参阅框架SDK文档以了解类概述。
Public constructors |
|
|---|---|
AsyncTaskLoader(Context context) |
|
公共方法(Public methods) |
|
|---|---|
void |
cancelLoadInBackground() 在主线程上调用以中止正在进行的加载。 |
void |
dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) 将Loader的状态打印到给定的流中。 |
boolean |
isLoadInBackgroundCanceled() 如果当前调用 |
abstract D |
loadInBackground() 调用工作线程来执行实际加载并返回加载操作的结果。 |
void |
onCanceled(D data) 如果任务在完成之前取消,则调用。 |
void |
setUpdateThrottle(long delayMS) 设置金额来限制更新。 |
Protected methods |
|
|---|---|
boolean |
onCancelLoad() 子类必须实现这个来处理对 |
void |
onForceLoad() 子类必须实现这个来处理对 |
D |
onLoadInBackground() 致电 |
继承方法(Inherited methods) |
|
|---|---|
android.support.v4.content.Loader
|
|
java.lang.Object
|
|
void cancelLoadInBackground ()
在主线程上调用以中止正在进行的加载。 重写此方法以中止正在工作线程后台运行的当前调用loadInBackground() 。 如果loadInBackground()尚未开始运行或已完成,则此方法不应执行任何操作。
也可以看看:
void dump (String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
将Loader的状态打印到给定的流中。
| 参数(Parameters) | |
|---|---|
prefix |
String: Text to print at the front of each line. |
fd |
FileDescriptor: The raw file descriptor that the dump is being sent to. |
writer |
PrintWriter: A PrintWriter to which the dump is to be set. |
args |
String: Additional arguments to the dump request. |
boolean isLoadInBackgroundCanceled ()
如果当前调用 loadInBackground()被取消,则返回true。
| 返回(Returns) | |
|---|---|
boolean |
True if the current invocation of loadInBackground() is being canceled. |
也可以看看:
D loadInBackground ()
调用工作线程来执行实际加载并返回加载操作的结果。 实现不应该直接提供结果,而应该从这个方法返回它们,最终最终会在UI线程上调用deliverResult(D) 。 如果实现需要在UI线程上处理结果,则它们可以覆盖deliverResult(D)并在那里执行。 为了支持取消,此方法应定期检查isLoadInBackgroundCanceled()的值,并在返回true时终止。 子类也可以覆盖cancelLoadInBackground()直接中断负载,而不是轮询isLoadInBackgroundCanceled() 。 当负载被取消时,这种方法可以正常返回或抛出OperationCanceledException 。 无论哪种情况, Loader都会调用onCanceled(D)来执行取消后清理并处理结果对象(如果有)。
| 返回(Returns) | |
|---|---|
D |
The result of the load operation. |
| 抛出异常(Throws) | |
|---|---|
OperationCanceledException |
if the load is canceled during execution. |
void onCanceled (D data)
如果任务在完成之前取消,则调用。 给班级一个机会清理后取消和妥善处理结果。
| 参数(Parameters) | |
|---|---|
data |
D: The value that was returned by loadInBackground(), or null if the task threw OperationCanceledException. |
void setUpdateThrottle (long delayMS)
设置金额来限制更新。 这是从最后一次loadInBackground()呼叫完成到预定新负载的最短时间。
| 参数(Parameters) | |
|---|---|
delayMS |
long: Amount of delay, in milliseconds. |
boolean onCancelLoad ()
子类必须实现这个来处理对cancelLoad()的请求。 这将始终从进程的主线程中调用。
| 返回(Returns) | |
|---|---|
boolean |
Returns false if the task could not be canceled, typically because it has already completed normally, or because startLoading() hasn't been called; returns true otherwise. When true is returned, the task is still running and the Loader.OnLoadCanceledListener will be called when the task completes. |
D onLoadInBackground ()
致电loadInBackground() 。 该方法保留供加载器框架使用。 子类应该覆盖loadInBackground()而不是此方法。
| 返回(Returns) | |
|---|---|
D |
The result of the load operation. |
| 抛出异常(Throws) | |
|---|---|
OperationCanceledException |
if the load is canceled during execution. |
也可以看看: