package com.kifile.android.cornerstone.impl.fetchers;

import com.kifile.android.cornerstone.core.DataFetcher;

import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;

/**
 * Fetch the cursor data from content provider.
 * <p/>
 * Do not forget close the cursor when not use.
 *
 * @author kifile
 */
public class CursorFetcher implements DataFetcher<Cursor> {

    private ContentResolver mResolver;

    private Uri mUri;

    private String[] mProjections;

    private String mSelection;

    private String[] mSelectionArgs;

    private String mOrderBy;

    public CursorFetcher(ContentResolver resolver, Uri uri) {
        mResolver = resolver;
        mUri = uri;
    }

    public CursorFetcher setProjection(String[] projections) {
        mProjections = projections;
        return this;
    }

    public CursorFetcher setSelection(String selection, String[] selectionArgs) {
        mSelection = selection;
        mSelectionArgs = selectionArgs;
        return this;
    }

    public CursorFetcher setOrderBy(String orderBy) {
        mOrderBy = orderBy;
        return this;
    }

    @Override
    public Cursor fetch() {
        return mResolver.query(mUri, mProjections, mSelection, mSelectionArgs, mOrderBy);
    }
}

@@ -1129,24 +1129,322 @@
 his;%0A    %7D%0A%0A
+    /**%0A     * If you want to change the params of fetcher, call it to reset the old params.%0A     *%0A     * @return%0A     */%0A    public CursorFetcher clear() %7B%0A        mProjections = null;%0A        mSelection = null;%0A        mSelectionArgs = null;%0A        mOrderBy = null;%0A        return this;%0A    %7D%0A%0A
     @Overrid

Add clear() method in CursorFetcher.