本文整理汇总了Java中android.database.MatrixCursor.RowBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java MatrixCursor.RowBuilder方法的具体用法?Java MatrixCursor.RowBuilder怎么用?Java MatrixCursor.RowBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.MatrixCursor
的用法示例。
在下文中一共展示了MatrixCursor.RowBuilder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMatrixCursor
import android.database.MatrixCursor; //导入方法依赖的package包/类
private MatrixCursor createMatrixCursor(Cursor cursor, int cursorOrigin) {
MatrixCursor matrixCursor = new MatrixCursor(suggestionsColumnNames, cursor.getCount());
MatrixCursor.RowBuilder builder;
if (cursor.moveToFirst()) {
do {
builder = matrixCursor.newRow();
if (cursorOrigin == RECENT_SEARCH_ORIGIN) {
builder.add(FindQuickSearchAdapter.HISTORY_ROW);
builder.add(cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_QUERY)));
} else {
builder.add(FindQuickSearchAdapter.DATABASE_ROW);
builder.add(cursor.getString(cursor.getColumnIndex(DbContract.FarmaciasEntity.NAME)));
}
} while (cursor.moveToNext());
}
cursor.close();
return matrixCursor;
}
示例2: transformListInToCursor
import android.database.MatrixCursor; //导入方法依赖的package包/类
public MatrixCursor transformListInToCursor(List<Pharmacy> pharmacyList) {
if (pharmacyList == null) return null;
String[] columnNames = {DbContract.FarmaciasEntity._ID,
DbContract.FarmaciasEntity.NAME,
DbContract.FarmaciasEntity.ADDRESS,
DbContract.FarmaciasEntity.LOCALITY,
DbContract.FarmaciasEntity.PROVINCE
};
MatrixCursor cursor = new MatrixCursor(columnNames, pharmacyList.size());
MatrixCursor.RowBuilder builder;
for (Pharmacy ph : pharmacyList) {
builder = cursor.newRow();
builder.add(ph.get_id());
builder.add(ph.getName());
builder.add(ph.getAddress());
builder.add(ph.getLocality());
builder.add(ph.getProvince());
}
return cursor;
}
示例3: mergeDates
import android.database.MatrixCursor; //导入方法依赖的package包/类
private MergeCursor mergeDates(long nextId, Map<Long, MatrixCursor> agenda) {
List<Cursor> allCursors = new ArrayList<>();
for (long dateMilli: agenda.keySet()) {
DateTime date = new DateTime(dateMilli);
MatrixCursor dateCursor = new MatrixCursor(Columns.AGENDA_SEPARATOR_COLS);
MatrixCursor.RowBuilder dateRow = dateCursor.newRow();
dateRow.add(nextId++);
dateRow.add(userTimeFormatter.formatDate(AgendaUtils.buildOrgDateTimeFromDate(date, null)));
dateRow.add(1); // Separator
allCursors.add(dateCursor);
allCursors.add(agenda.get(dateMilli));
}
return new MergeCursor(allCursors.toArray(new Cursor[allCursors.size()]));
}
示例4: queryRoots
import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public Cursor queryRoots(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_ROOT_PROJECTION);
// Add Home directory
File homeDir = Environment.getExternalStorageDirectory();
final MatrixCursor.RowBuilder row = result.newRow();
// These columns are required
row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
row.add(Root.COLUMN_TITLE, getContext().getString(R.string.internal_storage));
row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
row.add(Root.COLUMN_ICON, R.drawable.ic_provider);
// These columns are optional
row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
// Root.COLUMN_MIME_TYPE is another optional column and useful if you
// have multiple roots with different
// types of mime types (roots that don't match the requested mime type
// are automatically hidden)
return result;
}
示例5: includeFile
import android.database.MatrixCursor; //导入方法依赖的package包/类
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;
// We only show thumbnails for image files - expect a call to
// openDocumentThumbnail for each file that has
// 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
}
示例6: queryRoots
import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public Cursor queryRoots(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_ROOT_PROJECTION);
// Add Home directory
File homeDir = Environment.getExternalStorageDirectory();
final MatrixCursor.RowBuilder row = result.newRow();
// These columns are required
row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
row.add(Root.COLUMN_TITLE, "internal storage");
row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
//row.add(Root.COLUMN_ICON, R.drawable.ic_provider);
// These columns are optional
row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
// Root.COLUMN_MIME_TYPE is another optional column and useful if you
// have multiple roots with different
// types of mime types (roots that don't match the requested mime type
// are automatically hidden)
return result;
}
示例7: includeFile
import android.database.MatrixCursor; //导入方法依赖的package包/类
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;
// We only show thumbnails for image files - expect a call to
// openDocumentThumbnail for each file that has
// 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
}
示例8: queryFile
import android.database.MatrixCursor; //导入方法依赖的package包/类
public MatrixCursor.RowBuilder queryFile(AbstractTransport transport,
MatrixCursor result, String id) {
FEchoFile file_entry = transport.getFileMeta(id);
String filename = file_entry.filename;
if (!filename.contains(".") || !file_entry.existsLocally()) return null;
else {
MatrixCursor.RowBuilder row = result.newRow();
int dotindex = filename.lastIndexOf(".") + 1;
String extension = filename.substring(dotindex).toLowerCase();
String mimetype = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
row.add(DocumentsContract.Document.COLUMN_DOCUMENT_ID, "idecfile://" + id);
row.add(DocumentsContract.Document.COLUMN_DISPLAY_NAME, filename);
row.add(DocumentsContract.Document.COLUMN_FLAGS, null);
row.add(DocumentsContract.Document.COLUMN_MIME_TYPE, mimetype);
row.add(DocumentsContract.Document.COLUMN_SIZE, file_entry.serverSize);
row.add(DocumentsContract.Document.COLUMN_LAST_MODIFIED, null);
}
return null;
}
示例9: includeFile
import android.database.MatrixCursor; //导入方法依赖的package包/类
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 | Document.FLAG_SUPPORTS_RENAME
| (mimeType.equals(Document.MIME_TYPE_DIR) ? Document.FLAG_DIR_SUPPORTS_CREATE : 0) : 0;
// We only show thumbnails for image files - expect a call to openDocumentThumbnail for each file that has
// 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
}
示例10: queryRoots
import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public Cursor queryRoots(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_ROOT_PROJECTION);
// Add Home directory
File homeDir = Environment.getExternalStorageDirectory();
final MatrixCursor.RowBuilder row = result.newRow();
// These columns are required
row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
row.add(Root.COLUMN_TITLE, "Internal storage");
row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
row.add(Root.COLUMN_ICON, R.drawable.ic_provider);
// These columns are optional
row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
// Root.COLUMN_MIME_TYPE is another optional column and useful if you
// have multiple roots with different
// types of mime types (roots that don't match the requested mime type
// are automatically hidden)
return result;
}
示例11: queryRoots
import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public Cursor queryRoots(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_ROOT_PROJECTION);
// Add Home directory
File homeDir = Environment.getExternalStorageDirectory();
final MatrixCursor.RowBuilder row = result.newRow();
// These columns are required
row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
row.add(Root.COLUMN_TITLE, getContext().getString(R.string.internal_storage));
row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
row.add(Root.COLUMN_ICON, R.drawable.ic_shot_project);
// These columns are optional
row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
// Root.COLUMN_MIME_TYPE is another optional column and useful if you
// have multiple roots with different
// types of mime types (roots that don't match the requested mime type
// are automatically hidden)
return result;
}
示例12: includeFile
import android.database.MatrixCursor; //导入方法依赖的package包/类
/**
* Add a representation of a file to a cursor.
*
* @param result the cursor to modify
* @param file the File object representing the desired file (may be null if given docID)
*/
private void includeFile(MatrixCursor result, File file) {
MatrixCursor.RowBuilder row = result.newRow();
row.add(ImageContract.Columns.DISPLAY_NAME, file.getName());
row.add(ImageContract.Columns.SIZE, file.length());
row.add(ImageContract.Columns.ABSOLUTE_PATH, file.getAbsolutePath());
}
示例13: query
import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
final String[] selectionArgs, final String sortOrder) {
final Cursor source = super.query(uri, projection, selection, selectionArgs, sortOrder);
/*
It's not necessary to overwrite
public Cursor query(final Uri uri, final String[] projection, final String selection, final String[]
selectionArgs, final String sortOrder, final CancellationSignal cancellationSignal);
cause it calls this method.
== What's happening here? ==
Some apps rely on the MediaStore.MediaColumns.DATA column in the cursor. To prevent them
from crashing, we have to copy the initial cursor and add the MediaStore.MediaColumns.DATA
column. The values of this column will always be null, but we assume that they are able
to handle that case.
*/
if(source == null) {
Log.w(Belvedere.LOG_TAG, "Not able to apply workaround, super.query(...) returned null");
return null;
}
String[] columnNames = source.getColumnNames();
String[] newColumnNames = columnNamesWithData(columnNames);
final MatrixCursor cursor = new MatrixCursor(newColumnNames, source.getCount());
source.moveToPosition(-1);
while (source.moveToNext()) {
MatrixCursor.RowBuilder row = cursor.newRow();
for (int i = 0; i < columnNames.length; i++) {
row.add(source.getString(i));
}
}
source.close();
return cursor;
}
示例14: queryDocument
import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public Cursor queryDocument(String documentId, String[] projection) throws
FileNotFoundException {
// Create a cursor with the requested projection, or the default projection.
final MatrixCursor result = new
MatrixCursor(resolveDocumentProjection(projection));
MatrixCursor.RowBuilder row = result.newRow();
row.add(Document.COLUMN_DOCUMENT_ID, documentId);
if (TextUtils.equals(documentId, ROOT_DIRECTORY_ID)) {
row.add(Document.COLUMN_DISPLAY_NAME,
getContext().getResources().getString(R.string.app_name));
row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
row.add(Document.COLUMN_LAST_MODIFIED, null); // Not sure
row.add(Document.COLUMN_SIZE, null);
} else if (!documentId.contains("/")) {
// It is an experiment directory
// TODO: Use notifyChange to load data off-thread and update only when it is available.
List<GoosciUserMetadata.ExperimentOverview> overviews =
AppSingleton.getInstance(getContext()).getDataController()
.blockingGetExperimentOverviews(true);
for (GoosciUserMetadata.ExperimentOverview overview : overviews) {
if (TextUtils.equals(overview.experimentId, documentId)) {
addExperimentToRow(row, overview);
break;
}
}
} else {
// It is a file
File file = new File(FileMetadataManager.getExperimentsRootDirectory(getContext()) +
"/" + documentId);
addAssetToRow(row, file);
}
return result;
}
示例15: addExperimentToRow
import android.database.MatrixCursor; //导入方法依赖的package包/类
private void addExperimentToRow(MatrixCursor.RowBuilder row,
GoosciUserMetadata.ExperimentOverview overview) {
row.add(Document.COLUMN_DISPLAY_NAME, Experiment.getDisplayTitle(getContext(),
overview.title));
row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
row.add(Document.COLUMN_LAST_MODIFIED, overview.lastUsedTimeMs);
row.add(Document.COLUMN_SIZE, null);
}