Search in sources :

Example 91 with MatrixCursor

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

the class TestDocumentsProvider method queryRoots.

@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    Log.d(TAG, "Someone asked for our roots!");
    if (LAG)
        lagUntilCanceled(null);
    if (ROOTS_WEDGE)
        wedgeUntilCanceled(null);
    if (ROOTS_CRASH)
        System.exit(12);
    if (ROOTS_REFRESH) {
        new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... params) {
                SystemClock.sleep(3000);
                Log.d(TAG, "Notifying that something changed!!");
                final Uri uri = DocumentsContract.buildRootsUri(mAuthority);
                getContext().getContentResolver().notifyChange(uri, null, false);
                return null;
            }
        }.execute();
    }
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
    final RowBuilder row = result.newRow();
    row.add(Root.COLUMN_ROOT_ID, MY_ROOT_ID);
    row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_CREATE);
    row.add(Root.COLUMN_TITLE, "_Test title which is really long");
    row.add(Root.COLUMN_SUMMARY, SystemClock.elapsedRealtime() + " summary which is also super long text");
    row.add(Root.COLUMN_DOCUMENT_ID, MY_DOC_ID);
    row.add(Root.COLUMN_AVAILABLE_BYTES, 1024);
    return result;
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder) Uri(android.net.Uri) MatrixCursor(android.database.MatrixCursor)

Example 92 with MatrixCursor

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

the class TestDocumentsProvider method queryDocument.

@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
    if (LAG)
        lagUntilCanceled(null);
    if (DOCUMENT_CRASH)
        System.exit(12);
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    includeFile(result, documentId, 0);
    return result;
}
Also used : MatrixCursor(android.database.MatrixCursor)

Example 93 with MatrixCursor

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

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)

Example 94 with MatrixCursor

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

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 95 with MatrixCursor

use of android.database.MatrixCursor in project routerkeygenAndroid by routerkeygen.

the class LocalStorageProvider method queryDocument.

@Override
public Cursor queryDocument(final String documentId, final String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default
    // projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
    includeFile(result, new File(documentId));
    return result;
}
Also used : File(java.io.File) 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