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;
}
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);
}
}
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");
}
}
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);
}
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);
}
Aggregations