当前位置: 首页>>代码示例>>Java>>正文


Java MatrixCursor.moveToFirst方法代码示例

本文整理汇总了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;
}
 
开发者ID:afollestad,项目名称:polar-dashboard,代码行数:25,代码来源:TemplateProvider.java

示例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."
	);
}
 
开发者ID:universum-studios,项目名称:android_database,代码行数:22,代码来源:ModelCursorProcessorTest.java

示例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.");
}
 
开发者ID:universum-studios,项目名称:android_database,代码行数:23,代码来源:ModelCursorProcessorTest.java

示例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;
}
 
开发者ID:eduardb,项目名称:ClujBike,代码行数:13,代码来源:StationCursorMapperTest.java

示例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;
}
 
开发者ID:Technologx,项目名称:Fire-Bird-Dashboard-for-Zooper,代码行数:15,代码来源:TemplateProvider.java

示例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()));
}
 
开发者ID:universum-studios,项目名称:android_database,代码行数:10,代码来源:ModelCursorProcessorTest.java

示例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;
}
 
开发者ID:universum-studios,项目名称:android_database,代码行数:11,代码来源:TestModel.java


注:本文中的android.database.MatrixCursor.moveToFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。