use of android.database.MatrixCursor in project routerkeygenAndroid by routerkeygen.
the class LocalStorageProvider method includeFile.
private void includeFile(final MatrixCursor result, final File file) throws FileNotFoundException {
final MatrixCursor.RowBuilder row = result.newRow();
// These columns are required
row.add(Document.COLUMN_DOCUMENT_ID, file.getAbsolutePath());
row.add(Document.COLUMN_DISPLAY_NAME, file.getName());
String mimeType = getDocumentType(file.getAbsolutePath());
row.add(Document.COLUMN_MIME_TYPE, mimeType);
int flags = file.canWrite() ? Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE : 0;
// this flag set
if (mimeType.startsWith("image/"))
flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
row.add(Document.COLUMN_FLAGS, flags);
// COLUMN_SIZE is required, but can be null
row.add(Document.COLUMN_SIZE, file.length());
// These columns are optional
row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
// Document.COLUMN_ICON can be a resource id identifying a custom icon.
// The system provides default icons
// based on mime type
// Document.COLUMN_SUMMARY is optional additional information about the
// file
}
use of android.database.MatrixCursor in project muzei by romannurik.
the class MuzeiDocumentsProvider method queryDocument.
@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
ContentResolver contentResolver = getContext() != null ? getContext().getContentResolver() : null;
if (contentResolver == null) {
return result;
}
if (ROOT_DOCUMENT_ID.equals(documentId)) {
final MatrixCursor.RowBuilder row = result.newRow();
row.add(DocumentsContract.Document.COLUMN_DOCUMENT_ID, ROOT_DOCUMENT_ID);
row.add(DocumentsContract.Document.COLUMN_DISPLAY_NAME, getContext().getString(R.string.app_name));
row.add(DocumentsContract.Document.COLUMN_MIME_TYPE, DocumentsContract.Document.MIME_TYPE_DIR);
row.add(DocumentsContract.Document.COLUMN_FLAGS, 0);
row.add(DocumentsContract.Document.COLUMN_SIZE, null);
} else if (BY_DATE_DOCUMENT_ID.equals(documentId)) {
includeByDateRow(result.newRow());
} else if (BY_SOURCE_DOCUMENT_ID.equals(documentId)) {
includeBySourceRow(result.newRow());
} else if (documentId != null && documentId.startsWith(ARTWORK_DOCUMENT_ID_PREFIX)) {
long artworkId = Long.parseLong(documentId.replace(ARTWORK_DOCUMENT_ID_PREFIX, ""));
includeAllArtwork(result, contentResolver.query(ContentUris.withAppendedId(MuzeiContract.Artwork.CONTENT_URI, artworkId), ARTWORK_PROJECTION, null, null, null));
} else if (documentId != null && documentId.startsWith(SOURCE_DOCUMENT_ID_PREFIX)) {
long sourceId = Long.parseLong(documentId.replace(SOURCE_DOCUMENT_ID_PREFIX, ""));
includeAllSources(result, contentResolver.query(ContentUris.withAppendedId(MuzeiContract.Sources.CONTENT_URI, sourceId), SOURCE_PROJECTION, null, null, null));
}
return result;
}
use of android.database.MatrixCursor in project muzei by romannurik.
the class MuzeiDocumentsProvider method querySearchDocuments.
@Override
public Cursor querySearchDocuments(final String rootId, final String query, final String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
ContentResolver contentResolver = getContext() != null ? getContext().getContentResolver() : null;
if (contentResolver == null) {
return result;
}
String selection = MuzeiContract.Artwork.COLUMN_NAME_TITLE + " LIKE ? OR " + MuzeiContract.Artwork.COLUMN_NAME_BYLINE + " LIKE ? OR " + MuzeiContract.Artwork.COLUMN_NAME_ATTRIBUTION + " LIKE ?";
String likeAnyPositionQuery = "%" + query + "%";
includeAllArtwork(result, contentResolver.query(MuzeiContract.Artwork.CONTENT_URI, ARTWORK_PROJECTION, selection, new String[] { likeAnyPositionQuery, likeAnyPositionQuery, likeAnyPositionQuery }, MuzeiContract.Artwork.DEFAULT_SORT_ORDER));
return result;
}
use of android.database.MatrixCursor in project android_frameworks_base by crdroidandroid.
the class StubProvider method queryDocument.
@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
final StubDocument file = mStorage.get(documentId);
if (file == null) {
throw new FileNotFoundException();
}
includeDocument(result, file);
return result;
}
use of android.database.MatrixCursor in project android_frameworks_base by crdroidandroid.
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;
}
Aggregations