热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

android.database.MatrixCursor.moveToNext()方法的使用及代码示例

本文整理了Java中android.database.MatrixCursor.moveToNext()方法的一些代码示例,展示了MatrixCursor.

本文整理了Java中android.database.MatrixCursor.moveToNext()方法的一些代码示例,展示了MatrixCursor.moveToNext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MatrixCursor.moveToNext()方法的具体详情如下:
包路径:android.database.MatrixCursor
类名称:MatrixCursor
方法名:moveToNext

MatrixCursor.moveToNext介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldAddIterablesAsRows() throws Exception {
MatrixCursor cursor = new MatrixCursor(new String[]{"a", "b", "c"});
cursor.addRow(Arrays.asList(new Object[]{"foo", 10L, 0.1f}));
cursor.addRow(Arrays.asList(new Object[]{"baz", 20L, null}));
assertThat(cursor.getCount()).isEqualTo(2);
assertTrue(cursor.moveToFirst());
assertThat(cursor.getString(0)).isEqualTo("foo");
assertThat(cursor.getLong(1)).isEqualTo(10L);
assertThat(cursor.getFloat(2)).isEqualTo(0.1f);
assertTrue(cursor.moveToNext());
assertThat(cursor.getString(0)).isEqualTo("baz");
assertThat(cursor.getLong(1)).isEqualTo(20L);
assertTrue(cursor.isNull(2));
assertFalse(cursor.moveToNext());
}

代码示例来源:origin: robolectric/robolectric

@Test(expected = CursorIndexOutOfBoundsException.class)
public void shouldThrowIndexOutOfBoundsExceptionForInvalidColumnLastRow() throws Exception {
MatrixCursor cursor = new MatrixCursor(new String[]{"a", "b", "c"});
cursor.addRow(new Object[]{"foo", 10L, 0.1f});
cursor.moveToFirst();
cursor.moveToNext();
cursor.getString(0);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldAddObjectArraysAsRows() throws Exception {
MatrixCursor cursor = new MatrixCursor(new String[]{"a", "b", "c"});
cursor.addRow(new Object[]{"foo", 10L, 0.1f});
cursor.addRow(new Object[]{"baz", 20L, null});
assertThat(cursor.getCount()).isEqualTo(2);
assertTrue(cursor.moveToFirst());
assertThat(cursor.getString(0)).isEqualTo("foo");
assertThat(cursor.getLong(1)).isEqualTo(10L);
assertThat(cursor.getFloat(2)).isEqualTo(0.1f);
assertTrue(cursor.moveToNext());
assertThat(cursor.getString(0)).isEqualTo("baz");
assertThat(cursor.getLong(1)).isEqualTo(20L);
assertTrue(cursor.isNull(2));
assertFalse(cursor.moveToNext());
}

代码示例来源:origin: jberkel/sms-backup-plus

@Test public void testConvertMessagesSeenFlagFromMessageStatusWithSMS() throws Exception {
MatrixCursor cursor = new MatrixCursor(new String[] {Telephony.TextBasedSmsColumns.ADDRESS, Telephony.TextBasedSmsColumns.READ} );
cursor.addRow(new Object[]{ "foo", "0" });
cursor.addRow(new Object[]{ "foo", "1" });
cursor.moveToFirst();
PersonRecord record = mock(PersonRecord.class);
when(personLookup.lookupPerson(any(String.class))).thenReturn(record);
when(record.getAddress(any(AddressStyle.class))).thenReturn(new Address("foo"));
when(preferences.getMarkAsReadType()).thenReturn(MarkAsReadTypes.MESSAGE_STATUS);
messageCOnverter= new MessageConverter(RuntimeEnvironment.application,
preferences, "foo@example.com", personLookup, contactAccessor);
ConversionResult res = messageConverter.convertMessages(cursor, DataType.SMS);
assertThat(res.getMessages().get(0).isSet(Flag.SEEN)).isFalse();
cursor.moveToNext();
res = messageConverter.convertMessages(cursor, DataType.SMS);
assertThat(res.getMessages().get(0).isSet(Flag.SEEN)).isTrue();
}

代码示例来源:origin: jberkel/sms-backup-plus

@Test public void testConvertMessagesSeenFlagUnreadWithSMS() throws Exception {
MatrixCursor cursor = new MatrixCursor(new String[] {Telephony.TextBasedSmsColumns.ADDRESS, Telephony.TextBasedSmsColumns.READ} );
cursor.addRow(new Object[]{ "foo", "0" });
cursor.addRow(new Object[]{ "foo", "1" });
cursor.moveToFirst();
PersonRecord record = mock(PersonRecord.class);
when(personLookup.lookupPerson(any(String.class))).thenReturn(record);
when(record.getAddress(any(AddressStyle.class))).thenReturn(new Address("foo"));
when(preferences.getMarkAsReadType()).thenReturn(MarkAsReadTypes.UNREAD);
messageCOnverter= new MessageConverter(RuntimeEnvironment.application,
preferences, "foo@example.com", personLookup, contactAccessor);
ConversionResult res = messageConverter.convertMessages(cursor, DataType.SMS);
assertThat(res.getMessages().get(0).isSet(Flag.SEEN)).isFalse();
cursor.moveToNext();
res = messageConverter.convertMessages(cursor, DataType.SMS);
assertThat(res.getMessages().get(0).isSet(Flag.SEEN)).isFalse();
}

代码示例来源:origin: jberkel/sms-backup-plus

@Test public void testConvertMessagesSeenFlagReadWithSMS() throws Exception {
MatrixCursor cursor = new MatrixCursor(new String[] {Telephony.TextBasedSmsColumns.ADDRESS, Telephony.TextBasedSmsColumns.READ} );
cursor.addRow(new Object[]{ "foo", "0" });
cursor.addRow(new Object[]{ "foo", "1" });
cursor.moveToFirst();
PersonRecord record = mock(PersonRecord.class);
when(personLookup.lookupPerson(any(String.class))).thenReturn(record);
when(record.getAddress(any(AddressStyle.class))).thenReturn(new Address("foo"));
when(preferences.getMarkAsReadType()).thenReturn(MarkAsReadTypes.READ);
messageCOnverter= new MessageConverter(RuntimeEnvironment.application,
preferences, "foo@example.com", personLookup, contactAccessor);
ConversionResult res = messageConverter.convertMessages(cursor, DataType.SMS);
assertThat(res.getMessages().get(0).isSet(Flag.SEEN)).isTrue();
cursor.moveToNext();
res = messageConverter.convertMessages(cursor, DataType.SMS);
assertThat(res.getMessages().get(0).isSet(Flag.SEEN)).isTrue();
}

代码示例来源:origin: jahirfiquitiva/IconShowcase-Dashboard

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;
}

代码示例来源:origin: jahirfiquitiva/IconShowcase

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;
}

代码示例来源:origin: materialos/android-icon-pack

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;
}

代码示例来源:origin: stackoverflow.com

@Test
public void testCursor() {
MatrixCursor cursor = new MatrixCursor(new String[] { "id" });
for (String s : new String[] { "1", "2", "3" }) {
cursor.addRow(new String[] { s });
}
cursor.moveToPosition(0);
assertThat(cursor.moveToPrevious(), is(true));
cursor.moveToPosition(cursor.getCount()-1);
assertThat(cursor.moveToNext(), is(true));
assertThat(cursor.moveToPosition(c.getCount()), is(true));
assertThat(cursor.moveToPosition(-1), is(true));
}

代码示例来源:origin: stackoverflow.com

if (!cursorA.isLast()) cursorA.moveToNext();
if (!cursorB.isLast()) cursorB.moveToNext();
if (!cursorA.isAfterLast()) cursorA.moveToPrevious();

推荐阅读
author-avatar
bell723_893
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有