本文整理汇总了Java中android.database.MatrixCursor.RowBuilder类的典型用法代码示例。如果您正苦于以下问题:Java RowBuilder类的具体用法?Java RowBuilder怎么用?Java RowBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RowBuilder类属于android.database.MatrixCursor包,在下文中一共展示了RowBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCheckConnectionCursor
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
private MatrixCursor getCheckConnectionCursor(Uri uri) {
try
{
checkConnection(uri);
Log.d("KP2A_FC_P", "checking connection for " + uri + " ok.");
return null;
}
catch (Exception e)
{
Log.d("KP2A_FC_P","Check connection failed with: " + e.toString());
MatrixCursor matrixCursor = new MatrixCursor(BaseFileProviderUtils.CONNECTION_CHECK_CURSOR_COLUMNS);
RowBuilder newRow = matrixCursor.newRow();
String message = e.getLocalizedMessage();
if (message == null)
message = e.getMessage();
if (message == null)
message = e.toString();
newRow.add(message);
return matrixCursor;
}
}
示例2: addFileInfo
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
private RowBuilder addFileInfo(MatrixCursor matrixCursor, int id,
FileEntry f) {
int type = !f.isDirectory ? BaseFile.FILE_TYPE_FILE : BaseFile.FILE_TYPE_DIRECTORY;
RowBuilder newRow = matrixCursor.newRow();
newRow.add(id);// _ID
newRow.add(BaseFile
.genContentIdUriBase(
getAuthority())
.buildUpon().appendPath(f.path)
.build().toString());
newRow.add(f.path);
if (f.displayName == null)
Log.w("KP2AJ", "displayName is null for " + f.path);
newRow.add(f.displayName);
newRow.add(f.canRead ? 1 : 0);
newRow.add(f.canWrite ? 1 : 0);
newRow.add(f.sizeInBytes);
newRow.add(type);
if (f.lastModifiedTime > 0)
newRow.add(f.lastModifiedTime);
else
newRow.add(null);
newRow.add(FileUtils.getResIcon(type, f.displayName));
return newRow;
}
示例3: addDeletedFileInfo
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
private void addDeletedFileInfo(MatrixCursor matrixCursor, String filename) {
int type = BaseFile.FILE_TYPE_NOT_EXISTED;
RowBuilder newRow = matrixCursor.newRow();
newRow.add(0);// _ID
newRow.add(BaseFile
.genContentIdUriBase(
getAuthority())
.buildUpon().appendPath(filename)
.build().toString());
newRow.add(filename);
newRow.add(filename);
newRow.add(0);
newRow.add(0);
newRow.add(0);
newRow.add(type);
newRow.add(null);
newRow.add(FileUtils.getResIcon(type, filename));
}
示例4: query
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
@Override
public Cursor query(final Uri uri, final String[] projection, final String selection, final String[] selectionArgs, final String sortOrder)
{
final File file = new File(uri.getPath());
if (!file.getAbsolutePath().startsWith(getContext().getCacheDir().getAbsolutePath()))
throw new IllegalArgumentException("not in cache dir: " + uri);
final MatrixCursor cursor = new MatrixCursor(projection);
final RowBuilder row = cursor.newRow();
for (int i = 0; i < projection.length; i++)
{
final String columnName = projection[i];
if (columnName.equals(MediaStore.MediaColumns.DATA))
row.add(file.getAbsolutePath());
else if (columnName.equals(MediaStore.MediaColumns.SIZE))
row.add(file.length());
else if (columnName.equals(MediaStore.MediaColumns.DISPLAY_NAME))
row.add(uri.getLastPathSegment());
else
throw new IllegalArgumentException("cannot handle: " + columnName);
}
return cursor;
}
示例5: createPinnedSitesCursor
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
private Cursor createPinnedSitesCursor(Integer[] positions) {
MatrixCursor c = new MatrixCursor(PINNED_SITES_COLUMNS);
if (positions == null) {
return c;
}
for (int i = 0; i < positions.length; i++) {
int position = positions[i];
RowBuilder row = c.newRow();
row.add(-1);
row.add(PINNED_PREFIX + "url" + i);
row.add(PINNED_PREFIX + "title" + i);
row.add(position);
}
return c;
}
示例6: doRetrieveFileInfo
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
/**
* Retrieves file information of a single file.
*
* @param uri
* the URI pointing to a file.
* @return the file information. Can be {@code null}, based on the input
* parameters.
*/
private MatrixCursor doRetrieveFileInfo(Uri uri) {
MatrixCursor matrixCursor = BaseFileProviderUtils.newBaseFileCursor();
File file = extractFile(uri);
int type = file.isFile() ? BaseFile._FileTypeFile
: (file.isDirectory() ? BaseFile._FileTypeDirectory : (file
.exists() ? BaseFile._FileTypeUnknown
: BaseFile._FileTypeNotExisted));
RowBuilder newRow = matrixCursor.newRow();
newRow.add(0);// _ID
newRow.add(BaseFile.genContentIdUriBase(LocalFileContract._Authority)
.buildUpon().appendPath(Uri.fromFile(file).toString()).build()
.toString());
newRow.add(file.getAbsolutePath());
newRow.add(file.getName());
newRow.add(file.canRead() ? 1 : 0);
newRow.add(file.canWrite() ? 1 : 0);
newRow.add(file.length());
newRow.add(type);
newRow.add(file.lastModified());
newRow.add(FileUtils.getResIcon(type, file.getName()));
return matrixCursor;
}
示例7: doRetrieveFileInfo
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
/**
* Retrieves file information of a single file.
*
* @param uri
* the URI pointing to a file.
* @return the file information. Can be {@code null}, based on the input
* parameters.
*/
private MatrixCursor doRetrieveFileInfo(Uri uri) {
MatrixCursor matrixCursor = BaseFileProviderUtils.newBaseFileCursor();
File file = extractFile(uri);
int type = file.isFile() ? BaseFile.FILE_TYPE_FILE : (file
.isDirectory() ? BaseFile.FILE_TYPE_DIRECTORY
: (file.exists() ? BaseFile.FILE_TYPE_UNKNOWN
: BaseFile.FILE_TYPE_NOT_EXISTED));
RowBuilder newRow = matrixCursor.newRow();
newRow.add(0);// _ID
newRow.add(BaseFile
.genContentIdUriBase(
LocalFileContract.getAuthority(getContext()))
.buildUpon().appendPath(Uri.fromFile(file).toString()).build()
.toString());
newRow.add(Uri.fromFile(file).toString());
newRow.add(file.getName());
newRow.add(file.canRead() ? 1 : 0);
newRow.add(file.canWrite() ? 1 : 0);
newRow.add(file.length());
newRow.add(type);
newRow.add(file.lastModified());
newRow.add(FileUtils.getResIcon(type, file.getName()));
return matrixCursor;
}
示例8: addRow
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
private void addRow(MatrixCursor c, String url, String title, int type, String data) {
final RowBuilder row = c.newRow();
row.add(-1);
row.add(url);
row.add(title);
row.add(type);
row.add(data);
}
示例9: createTopSitesCursor
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
private Cursor createTopSitesCursor(int count) {
MatrixCursor c = new MatrixCursor(TOP_SITES_COLUMNS);
for (int i = 0; i < count; i++) {
RowBuilder row = c.newRow();
row.add(-1);
row.add(TOP_PREFIX + "url" + i);
row.add(TOP_PREFIX + "title" + i);
row.add(i);
row.add(i);
}
return c;
}
示例10: createSuggestedSitesCursor
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
private Cursor createSuggestedSitesCursor(int count) {
MatrixCursor c = new MatrixCursor(SUGGESTED_SITES_COLUMNS);
for (int i = 0; i < count; i++) {
RowBuilder row = c.newRow();
row.add(-1);
row.add(SUGGESTED_PREFIX + "url" + i);
row.add(SUGGESTED_PREFIX + "title" + i);
}
return c;
}
示例11: includeDefault
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
public void includeDefault() {
final ArrayList<String> defaultColumns =
new ArrayList<>(songsColumns.length + 1);
defaultColumns.addAll(Arrays.asList(songsColumns));
defaultColumns.add(BaseColumns._ID);
final MatrixCursor defaultsCursor = new MatrixCursor(defaultColumns.toArray(
new String[defaultColumns.size()]));
RowBuilder row = defaultsCursor.newRow();
row.add("Default");
row.add(DEFAULT_TONE_INDEX);
includeStaticCursor(defaultsCursor);
}
示例12: query
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
public static Cursor query( Context context ) {
MatrixCursor cursor = new MatrixCursor( new String [] {
KEY
}, 1 );
Status status = Status.from( context );
RowBuilder row = cursor.newRow();
row.add( Integer.valueOf( status.value() ) );
return cursor;
}
示例13: queryRoots
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
final RowBuilder row = result.newRow();
row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT);
row.add(Root.COLUMN_FLAGS,
Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_CREATE);
row.add(Root.COLUMN_ICON, R.mipmap.ic_launcher_download);
row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_downloads));
row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
return result;
}
示例14: includeDefaultDocument
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
private void includeDefaultDocument(MatrixCursor result) {
final RowBuilder row = result.newRow();
row.add(Document.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
row.add(Document.COLUMN_FLAGS,
Document.FLAG_DIR_PREFERS_LAST_MODIFIED | Document.FLAG_DIR_SUPPORTS_CREATE);
}
示例15: appendNameAndRealUri
import android.database.MatrixCursor.RowBuilder; //导入依赖的package包/类
/**
* Appends file name and real URI into {@code cursor}.
*
* @param cursor
* the original cursor. It will be closed when done.
* @return the new cursor.
*/
private Cursor appendNameAndRealUri(Cursor cursor) {
if (cursor == null || cursor.getCount() == 0)
return cursor;
final int colUri = cursor.getColumnIndex(HistoryContract.COLUMN_URI);
if (colUri < 0)
return cursor;
String[] columns = new String[cursor.getColumnCount()
+ ADDITIONAL_COLUMNS.length];
System.arraycopy(cursor.getColumnNames(), 0, columns, 0,
cursor.getColumnCount());
System.arraycopy(ADDITIONAL_COLUMNS, 0, columns,
cursor.getColumnCount(), ADDITIONAL_COLUMNS.length);
MatrixCursor result = new MatrixCursor(columns);
if (cursor.moveToFirst()) {
do {
RowBuilder builder = result.newRow();
Cursor fileInfo = null;
for (int i = 0; i < cursor.getColumnCount(); i++) {
String data = cursor.getString(i);
builder.add(data);
if (i == colUri)
fileInfo = getContext().getContentResolver().query(
Uri.parse(data), null, null, null, null);
}
if (fileInfo != null) {
if (fileInfo.moveToFirst()) {
builder.add(BaseFileProviderUtils.getFileName(fileInfo));
builder.add(BaseFileProviderUtils.getRealUri(fileInfo)
.toString());
}
fileInfo.close();
}
} while (cursor.moveToNext());
}// if
cursor.close();
return result;
}