@@ -0,0 +1,2693 @@
+%0Apackage com.uwetrottmann.shopr.loaders;%0A%0Aimport android.content.Context;%0Aimport android.support.v4.content.AsyncTaskLoader;%0A%0Aimport java.util.List;%0A%0A/**%0A * A generic %7B@link AsyncTaskLoader%7D loading any %7B@link List%7D or single object%0A * of things (beware for e.g. Cursors you need to override onReleaseResources in%0A * a meaningful way). It takes care of delivering and reseting results, so you%0A * only have to implement %3Ccode%3EloadInBackground()%3C/code%3E.%0A */%0Apublic abstract class GenericSimpleLoader%3CT%3E extends AsyncTaskLoader%3CT%3E %7B%0A%0A    protected T mItems;%0A%0A    public GenericSimpleLoader(Context context) %7B%0A        super(context);%0A    %7D%0A%0A    /**%0A     * Called when there is new data to deliver to the client. The super class%0A     * will take care of delivering it; the implementation here just adds a%0A     * little more logic.%0A     */%0A    @Override%0A    public void deliverResult(T items) %7B%0A        if (isReset()) %7B%0A            // An async query came in while the loader is stopped. We%0A            // don't need the result.%0A            if (items != null) %7B%0A                onReleaseResources(items);%0A            %7D%0A        %7D%0A        T oldItems = items;%0A        mItems = items;%0A%0A        if (isStarted()) %7B%0A            // If the Loader is currently started, we can immediately%0A            // deliver its results.%0A            super.deliverResult(items);%0A        %7D%0A%0A        if (oldItems != null) %7B%0A            onReleaseResources(oldItems);%0A        %7D%0A    %7D%0A%0A    @Override%0A    protected void onStartLoading() %7B%0A        if (mItems != null) %7B%0A            deliverResult(mItems);%0A        %7D else %7B%0A            forceLoad();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Handles a request to stop the Loader.%0A     */%0A    @Override%0A    protected void onStopLoading() %7B%0A        // Attempt to cancel the current load task if possible.%0A        cancelLoad();%0A    %7D%0A%0A    /**%0A     * Handles a request to cancel a load.%0A     */%0A    @Override%0A    public void onCanceled(T items) %7B%0A        super.onCanceled(items);%0A%0A        onReleaseResources(items);%0A    %7D%0A%0A    /**%0A     * Handles a request to completely reset the Loader.%0A     */%0A    @Override%0A    protected void onReset() %7B%0A        super.onReset();%0A%0A        // Ensure the loader is stopped%0A        onStopLoading();%0A%0A        // At this point we can release resources%0A        if (mItems != null) %7B%0A            onReleaseResources(mItems);%0A            mItems = null;%0A        %7D%0A    %7D%0A%0A    /**%0A     * Helper function to take care of releasing resources associated with an%0A     * actively loaded data set.%0A     */%0A    protected void onReleaseResources(T items) %7B%0A        // For simple items there is nothing to do. For something%0A        // like a Cursor, we would close it here.%0A    %7D%0A%0A%7D%0A

Add generic simple loader.