本文整理汇总了Java中android.database.MatrixCursor.moveToFirst方法的典型用法代码示例。如果您正苦于以下问题:Java MatrixCursor.moveToFirst方法的具体用法?Java MatrixCursor.moveToFirst怎么用?Java MatrixCursor.moveToFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.MatrixCursor
的用法示例。
在下文中一共展示了MatrixCursor.moveToFirst方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import android.database.MatrixCursor; //导入方法依赖的package包/类
public Cursor query(
@NonNull Uri paramUri,
String[] paramArrayOfString1,
String paramString1,
String[] paramArrayOfString2,
String paramString2) {
MatrixCursor cursor = new MatrixCursor(new String[] {"string"});
try {
if (getContext() == null) {
return cursor;
}
final String path = paramUri.getPath().substring(1);
final String[] items = getContext().getAssets().list(path);
for (String s : items) {
cursor.newRow().add(s);
cursor.moveToNext();
}
cursor.moveToFirst();
} catch (Exception e) {
cursor.close();
throw new RuntimeException(e);
}
return cursor;
}
示例2: testProcessModelWithUnsupportedColumns
import android.database.MatrixCursor; //导入方法依赖的package包/类
@Test
public void testProcessModelWithUnsupportedColumns() {
final MatrixCursor testCursor = new MatrixCursor(new String[]{"date"}, 1);
testCursor.addRow(new Object[]{0});
testCursor.moveToFirst();
assertThatProcessingThrowsExceptionWithMessage(
new Runnable() {
@Override
public void run() {
mProcessor.processModel(
mModelWithUnsupportedColumns,
mUnsupportedColumns,
testCursor
);
}
},
"Failed to attach value from Cursor to column field. " +
"Field(TestModelWithUnsupportedColumns.date) type of(Date) is not allowed to represent a column. " +
"Only primitive type fields, Enums including, are allowed as columns."
);
}
示例3: testOnProcessColumnOfUnsupportedType
import android.database.MatrixCursor; //导入方法依赖的package包/类
@Test
public void testOnProcessColumnOfUnsupportedType() throws Exception {
final MatrixCursor cursor = new MatrixCursor(new String[]{"date"}, 1);
cursor.addRow(new Object[]{0});
cursor.moveToFirst();
final AnnotatedColumn annotatedColumn = new TestAnnotatedColumn(TestModelWithUnsupportedColumns.class.getField("date"));
final ModelCursorProcessor.CursorTask task = ModelCursorProcessor.CursorTask.obtainFor(mModelWithUnsupportedColumns, mUnsupportedColumns, cursor);
try {
mProcessor.onProcessColumn(task, annotatedColumn);
} catch (DatabaseException e) {
assertThat(e.getType(), is(DatabaseException.TYPE_MISCONFIGURATION));
assertThat(
e.getMessage(),
is("Failed to attach value from Cursor to column field. " +
"Field(TestModelWithUnsupportedColumns.date) type of(Date) " +
"is not allowed to represent a column. " +
"Only primitive type fields, Enums including, are allowed as columns.")
);
return;
}
throw new AssertionError("No exception thrown.");
}
示例4: givenCursor
import android.database.MatrixCursor; //导入方法依赖的package包/类
private Cursor givenCursor(boolean hasRows) {
String[] columns = new String[]{"_id", "name", "address", "occupiedSpots",
"emptySpots", "maximumNumberOfBikes", "lastSyncDate", "idStatus", "status",
"statusType", "latitude", "longitude", "isValid", "customIsValid"};
MatrixCursor cursor = new MatrixCursor(columns);
if (hasRows) {
cursor.addRow(new Object[]{12, "Union Square", "Manhattan", 2, 4, 6,
System.currentTimeMillis(), 0, 0, 1, 35.55f, 34.44f, 0, 1});
cursor.moveToFirst();
}
return cursor;
}
示例5: query
import android.database.MatrixCursor; //导入方法依赖的package包/类
public Cursor query(Uri paramUri, String[] paramArrayOfString1, String paramString1, String[] paramArrayOfString2, String paramString2) {
MatrixCursor cursor = new MatrixCursor(new String[]{"string"});
try {
final String path = paramUri.getPath().substring(1);
for (String s : getContext().getAssets().list(path)) {
cursor.newRow().add(s);
cursor.moveToNext();
}
cursor.moveToFirst();
} catch (Exception e) {
e.printStackTrace();
}
return cursor;
}
示例6: testAttachValueToColumnAsEnumWithEmptyNameValue
import android.database.MatrixCursor; //导入方法依赖的package包/类
@Test
public void testAttachValueToColumnAsEnumWithEmptyNameValue() throws Exception {
final MatrixCursor cursor = new MatrixCursor(new String[]{TestModelEntity.Columns.DIFFICULTY}, 1);
cursor.addRow(new Object[]{""});
cursor.moveToFirst();
final AnnotatedColumn annotatedColumn = new TestAnnotatedColumn(TestModel.class.getField("difficulty"));
assertThat(mProcessor.attachValueToColumn(annotatedColumn, mModel, cursor, cursor.getColumnIndex(TestModelEntity.Columns.DIFFICULTY)), is(true));
assertThat(mModel.difficulty, is(nullValue()));
}
示例7: createCursorWithTestValues
import android.database.MatrixCursor; //导入方法依赖的package包/类
public static Cursor createCursorWithTestValues(int rowsCount) {
final MatrixCursor cursor = new MatrixCursor(TestModelEntity.ALL_ENTITY_COLUMNS, rowsCount);
for (int i = 0; i < rowsCount; i++) {
final Object[] values = TestUtils.copyOf(TestModel.ALL_TEST_VALUES, TestModel.ALL_TEST_VALUES.length);
values[COLUMN_INDEX_ID] = i + 1;
cursor.addRow(values);
}
cursor.moveToFirst();
return cursor;
}