Code example for AsyncTaskLoader

0
 
class RepairListLoader extends AsyncTaskLoader<ArrayList<String>> {
	private ArrayList<String> mData;
	private BotBrewApp mApplication;
	public RepairListLoader(Context ctx) {
		super(ctx);
		mApplication = (BotBrewApp)ctx.getApplicationContext();
	} 
	@Override 
	public void onStartLoading() { 
		if(mData != null) deliverResult(mData);	// deliver loaded data
		else forceLoad(); // start AsyncTask
	} 
	@Override 
	public void deliverResult(ArrayList<String> data) {
		mData = data;		// cache that stuff
		if(isStarted()) super.deliverResult(mData);	// deliver if loader wasn't stopped or canceled
	} 
	@Override 
	public void onReset() {