Search in sources :

Example 16 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by DirtyUnicorns.

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 17 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by DirtyUnicorns.

the class ExternalStorageProvider method includeFile.

private void includeFile(MatrixCursor result, String docId, File file) throws FileNotFoundException {
    if (docId == null) {
        docId = getDocIdForFile(file);
    } else {
        file = getFileForDocId(docId);
    }
    int flags = 0;
    if (file.canWrite()) {
        if (file.isDirectory()) {
            flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
            flags |= Document.FLAG_SUPPORTS_DELETE;
            flags |= Document.FLAG_SUPPORTS_RENAME;
            flags |= Document.FLAG_SUPPORTS_MOVE;
        } else {
            flags |= Document.FLAG_SUPPORTS_WRITE;
            flags |= Document.FLAG_SUPPORTS_DELETE;
            flags |= Document.FLAG_SUPPORTS_RENAME;
            flags |= Document.FLAG_SUPPORTS_MOVE;
        }
    }
    final String mimeType = getTypeForFile(file);
    if (mArchiveHelper.isSupportedArchiveType(mimeType)) {
        flags |= Document.FLAG_ARCHIVE;
    }
    final String displayName = file.getName();
    if (mimeType.startsWith("image/")) {
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    }
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, displayName);
    row.add(Document.COLUMN_SIZE, file.length());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    row.add(Document.COLUMN_FLAGS, flags);
    row.add(DocumentArchiveHelper.COLUMN_LOCAL_FILE_PATH, file.getPath());
    // Only publish dates reasonably after epoch
    long lastModified = file.lastModified();
    if (lastModified > 31536000000L) {
        row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
    }
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder) Point(android.graphics.Point)

Example 18 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by DirtyUnicorns.

the class TestDocumentsProvider method includeFile.

private static void includeFile(MatrixCursor result, String docId, int flags) {
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, docId);
    row.add(Document.COLUMN_DISPLAY_NAME, docId);
    row.add(Document.COLUMN_LAST_MODIFIED, System.currentTimeMillis());
    row.add(Document.COLUMN_FLAGS, flags);
    if (MY_DOC_ID.equals(docId)) {
        row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
        row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_SUPPORTS_CREATE);
    } else if (MY_DOC_NULL.equals(docId)) {
    // No MIME type
    } else {
        row.add(Document.COLUMN_MIME_TYPE, "application/octet-stream");
    }
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder)

Example 19 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by DirtyUnicorns.

the class StressProvider method includeDocument.

private void includeDocument(MatrixCursor result, StubDocument document) {
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, document.id);
    row.add(Document.COLUMN_DISPLAY_NAME, document.id);
    row.add(Document.COLUMN_SIZE, document.size);
    row.add(Document.COLUMN_MIME_TYPE, document.mimeType);
    row.add(Document.COLUMN_FLAGS, document.thumbnail != -1 ? Document.FLAG_SUPPORTS_THUMBNAIL : 0);
    row.add(Document.COLUMN_LAST_MODIFIED, document.lastModified);
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder)

Example 20 with RowBuilder

use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by DirtyUnicorns.

the class StressProvider method includeRoot.

private void includeRoot(MatrixCursor result, StubRoot root) {
    final RowBuilder row = result.newRow();
    row.add(Root.COLUMN_ROOT_ID, root.id);
    row.add(Root.COLUMN_FLAGS, 0);
    row.add(Root.COLUMN_TITLE, root.id);
    row.add(Root.COLUMN_DOCUMENT_ID, root.documentId);
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder)

Aggregations

RowBuilder (android.database.MatrixCursor.RowBuilder)60 MatrixCursor (android.database.MatrixCursor)30 ContentValues (android.content.ContentValues)5 Cursor (android.database.Cursor)5 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)5 Point (android.graphics.Point)5 Uri (android.net.Uri)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5