Search in sources :

Example 51 with MatrixCursor

use of android.database.MatrixCursor in project android_frameworks_base by ResurrectionRemix.

the class StubProvider method querySearchDocuments.

@Override
public Cursor querySearchDocuments(String rootId, String query, String[] projection) throws FileNotFoundException {
    StubDocument parentDocument = mRoots.get(rootId).document;
    if (parentDocument == null || parentDocument.file.isFile()) {
        throw new FileNotFoundException();
    }
    final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
    for (File file : parentDocument.file.listFiles()) {
        if (file.getName().toLowerCase().contains(query)) {
            StubDocument document = mStorage.get(getDocumentIdForFile(file));
            if (document != null) {
                includeDocument(result, document);
            }
        }
    }
    return result;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) MatrixCursor(android.database.MatrixCursor)

Example 52 with MatrixCursor

use of android.database.MatrixCursor in project android_frameworks_base by ResurrectionRemix.

the class BugreportStorageProvider method queryRoots.

@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
    final RowBuilder row = result.newRow();
    row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT);
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_ADVANCED);
    row.add(Root.COLUMN_ICON, android.R.mipmap.sym_def_app_icon);
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.bugreport_storage_title));
    row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
    return result;
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder) MatrixCursor(android.database.MatrixCursor)

Example 53 with MatrixCursor

use of android.database.MatrixCursor in project android_frameworks_base by ResurrectionRemix.

the class ExternalStorageProvider method querySearchDocuments.

@Override
public Cursor querySearchDocuments(String rootId, String query, String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    query = query.toLowerCase();
    final File parent;
    synchronized (mRootsLock) {
        parent = mRoots.get(rootId).path;
    }
    final LinkedList<File> pending = new LinkedList<File>();
    pending.add(parent);
    while (!pending.isEmpty() && result.getCount() < 24) {
        final File file = pending.removeFirst();
        if (file.isDirectory()) {
            for (File child : file.listFiles()) {
                pending.add(child);
            }
        }
        if (file.getName().toLowerCase().contains(query)) {
            includeFile(result, null, file);
        }
    }
    return result;
}
Also used : File(java.io.File) MatrixCursor(android.database.MatrixCursor) LinkedList(java.util.LinkedList)

Example 54 with MatrixCursor

use of android.database.MatrixCursor in project android_frameworks_base by ResurrectionRemix.

the class ExternalStorageProvider method queryChildDocuments.

@Override
public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException {
    if (mArchiveHelper.isArchivedDocument(parentDocumentId) || mArchiveHelper.isSupportedArchiveType(getDocumentType(parentDocumentId))) {
        return mArchiveHelper.queryChildDocuments(parentDocumentId, projection, sortOrder);
    }
    final File parent = getFileForDocId(parentDocumentId);
    final MatrixCursor result = new DirectoryCursor(resolveDocumentProjection(projection), parentDocumentId, parent);
    for (File file : parent.listFiles()) {
        includeFile(result, null, file);
    }
    return result;
}
Also used : File(java.io.File) MatrixCursor(android.database.MatrixCursor)

Example 55 with MatrixCursor

use of android.database.MatrixCursor in project android_frameworks_base by ResurrectionRemix.

the class ExternalStorageProvider method queryDocument.

@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
    if (mArchiveHelper.isArchivedDocument(documentId)) {
        return mArchiveHelper.queryDocument(documentId, projection);
    }
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    includeFile(result, documentId, null);
    return result;
}
Also used : MatrixCursor(android.database.MatrixCursor)

Aggregations

MatrixCursor (android.database.MatrixCursor)259 Cursor (android.database.Cursor)37 DirectoryResult (com.android.documentsui.DirectoryResult)35 RowBuilder (android.database.MatrixCursor.RowBuilder)30 File (java.io.File)30 MergeCursor (android.database.MergeCursor)18 Uri (android.net.Uri)18 Test (org.junit.Test)17 Setting (com.android.providers.settings.SettingsState.Setting)15 FileNotFoundException (java.io.FileNotFoundException)15 ArrayList (java.util.ArrayList)13 Bundle (android.os.Bundle)10 BitSet (java.util.BitSet)10 Random (java.util.Random)10 IOException (java.io.IOException)7 LinkedList (java.util.LinkedList)7 ContentValues (android.content.ContentValues)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)5