本文整理匯總了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;
}