/** * Handles a request to start the Loader. */ @Override protectedvoidonStartLoading() { if (mData != null) { // If we currently have a result available, deliver it // immediately. deliverResult(mData); }
registerObserver();
if (takeContentChanged() || mData == null || isConfigChanged()) { // If the data has changed since the last time it was loaded // or is not currently available, start a load. forceLoad(); } }
/** * Called when there is new data to deliver to the client. The super class * will take care of delivering it; the implementation here just adds a * little more logic. */ @Override publicvoiddeliverResult(T data) { if (isReset()) { // An async query came in while the loader is stopped. We // don't need the result. if (mData != null) { onReleaseResources(mData); } } ToldApps= mData; mData = data;
if (isStarted()) { // If the Loader is currently started, we can immediately // deliver its results. super.deliverResult(data); }
// At this point we can release the resources associated with // 'oldApps' if needed; now that the new result is delivered we // know that it is no longer in use. if (oldApps != null) { onReleaseResources(oldApps); } }
/** * Handles a request to stop the Loader. */ @Override protectedvoidonStopLoading() { // Attempt to cancel the current load task if possible. cancelLoad(); }
/** * Handles a request to cancel a load. */ @Override publicvoidonCanceled(T data) { super.onCanceled(data);
// At this point we can release the resources associated with 'apps' // if needed. onReleaseResources(data); }
/** * Handles a request to completely reset the Loader. */ @Override protectedvoidonReset() { super.onReset();
// Ensure the loader is stopped onStopLoading();
// At this point we can release the resources associated with 'apps' // if needed. if (mData != null) { onReleaseResources(mData); mData = null; }