當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。