Back to project page CATaZine-Live.
The source code is released under:
GNU General Public License
If you think the Android project CATaZine-Live listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.melegy.catazine.loader; /*from w ww . j av a 2s . c o m*/ import android.content.AsyncTaskLoader; import android.content.Context; public abstract class BaseLoader<D> extends AsyncTaskLoader<D> { private D data; public BaseLoader(Context context) { super(context); } @Override public void deliverResult(D data) { if (isReset()) { // An async query came in while the loader is stopped return; } this.data = data; super.deliverResult(data); } @Override protected void onStartLoading() { if (data != null) { deliverResult(data); } if (takeContentChanged() || data == null) { forceLoad(); } } @Override protected void onStopLoading() { // Attempt to cancel the current load task if possible. cancelLoad(); } @Override protected void onReset() { super.onReset(); // Ensure the loader is stopped onStopLoading(); data = null; } }