Search in sources :

Example 21 with RowBuilder

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

the class StubProvider method includeDocument.

private void includeDocument(MatrixCursor result, StubDocument document) {
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, document.documentId);
    row.add(Document.COLUMN_DISPLAY_NAME, document.file.getName());
    row.add(Document.COLUMN_SIZE, document.file.length());
    row.add(Document.COLUMN_MIME_TYPE, document.mimeType);
    row.add(Document.COLUMN_FLAGS, document.flags);
    row.add(Document.COLUMN_LAST_MODIFIED, document.file.lastModified());
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder)

Example 22 with RowBuilder

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

the class StubProvider method queryRoots.

@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_ROOT_PROJECTION);
    for (Map.Entry<String, RootInfo> entry : mRoots.entrySet()) {
        final String id = entry.getKey();
        final RootInfo info = entry.getValue();
        final RowBuilder row = result.newRow();
        row.add(Root.COLUMN_ROOT_ID, id);
        row.add(Root.COLUMN_FLAGS, info.flags);
        row.add(Root.COLUMN_TITLE, id);
        row.add(Root.COLUMN_DOCUMENT_ID, info.document.documentId);
        row.add(Root.COLUMN_AVAILABLE_BYTES, info.getRemainingCapacity());
    }
    return result;
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder) HashMap(java.util.HashMap) Map(java.util.Map) MatrixCursor(android.database.MatrixCursor)

Example 23 with RowBuilder

use of android.database.MatrixCursor.RowBuilder 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 24 with RowBuilder

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

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

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

the class StubProvider method includeDocument.

private void includeDocument(MatrixCursor result, StubDocument document) {
    final RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, document.documentId);
    row.add(Document.COLUMN_DISPLAY_NAME, document.file.getName());
    row.add(Document.COLUMN_SIZE, document.file.length());
    row.add(Document.COLUMN_MIME_TYPE, document.mimeType);
    row.add(Document.COLUMN_FLAGS, document.flags);
    row.add(Document.COLUMN_LAST_MODIFIED, document.file.lastModified());
}
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