FileDocCategorySizeDatePackage
FilteringCursorWrapper.javaAPI DocAndroid 5.1 API3852Thu Mar 12 22:22:40 GMT 2015com.android.documentsui

FilteringCursorWrapper

public class FilteringCursorWrapper extends android.database.AbstractCursor
Cursor wrapper that filters MIME types not matching given list.

Fields Summary
private final android.database.Cursor
mCursor
private final int[]
mPosition
private int
mCount
Constructors Summary
public FilteringCursorWrapper(android.database.Cursor cursor, String[] acceptMimes)

        this(cursor, acceptMimes, null, Long.MIN_VALUE);
    
public FilteringCursorWrapper(android.database.Cursor cursor, String[] acceptMimes, String[] rejectMimes)

        this(cursor, acceptMimes, rejectMimes, Long.MIN_VALUE);
    
public FilteringCursorWrapper(android.database.Cursor cursor, String[] acceptMimes, String[] rejectMimes, long rejectBefore)

        mCursor = cursor;

        final int count = cursor.getCount();
        mPosition = new int[count];

        cursor.moveToPosition(-1);
        while (cursor.moveToNext() && mCount < count) {
            final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
            final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
            if (rejectMimes != null && MimePredicate.mimeMatches(rejectMimes, mimeType)) {
                continue;
            }
            if (lastModified < rejectBefore) {
                continue;
            }
            if (MimePredicate.mimeMatches(acceptMimes, mimeType)) {
                mPosition[mCount++] = cursor.getPosition();
            }
        }

        Log.d(TAG, "Before filtering " + cursor.getCount() + ", after " + mCount);
    
Methods Summary
public voidclose()

        super.close();
        mCursor.close();
    
public java.lang.String[]getColumnNames()

        return mCursor.getColumnNames();
    
public intgetCount()

        return mCount;
    
public doublegetDouble(int column)

        return mCursor.getDouble(column);
    
public android.os.BundlegetExtras()

        return mCursor.getExtras();
    
public floatgetFloat(int column)

        return mCursor.getFloat(column);
    
public intgetInt(int column)

        return mCursor.getInt(column);
    
public longgetLong(int column)

        return mCursor.getLong(column);
    
public shortgetShort(int column)

        return mCursor.getShort(column);
    
public java.lang.StringgetString(int column)

        return mCursor.getString(column);
    
public intgetType(int column)

        return mCursor.getType(column);
    
public booleanisNull(int column)

        return mCursor.isNull(column);
    
public booleanonMove(int oldPosition, int newPosition)

        return mCursor.moveToPosition(mPosition[newPosition]);