本文整理汇总了Java中android.database.MergeCursor类的典型用法代码示例。如果您正苦于以下问题:Java MergeCursor类的具体用法?Java MergeCursor怎么用?Java MergeCursor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MergeCursor类属于android.database包,在下文中一共展示了MergeCursor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnarchivedConversationList
import android.database.MergeCursor; //导入依赖的package包/类
private Cursor getUnarchivedConversationList() {
List<Cursor> cursorList = new LinkedList<>();
cursorList.add(DatabaseFactory.getThreadDatabase(context).getConversationList());
int archivedCount = DatabaseFactory.getThreadDatabase(context)
.getArchivedConversationListCount();
if (archivedCount > 0) {
MatrixCursor switchToArchiveCursor = new MatrixCursor(new String[] {
ThreadDatabase.ID, ThreadDatabase.DATE, ThreadDatabase.MESSAGE_COUNT,
ThreadDatabase.RECIPIENT_IDS, ThreadDatabase.SNIPPET, ThreadDatabase.READ,
ThreadDatabase.TYPE, ThreadDatabase.SNIPPET_TYPE, ThreadDatabase.SNIPPET_URI,
ThreadDatabase.ARCHIVED, ThreadDatabase.STATUS, ThreadDatabase.RECEIPT_COUNT,
ThreadDatabase.EXPIRES_IN, ThreadDatabase.LAST_SEEN}, 1);
switchToArchiveCursor.addRow(new Object[] {-1L, System.currentTimeMillis(), archivedCount,
"-1", null, 1, ThreadDatabase.DistributionTypes.ARCHIVE,
0, null, 0, -1, 0, 0, 0});
cursorList.add(switchToArchiveCursor);
}
return new MergeCursor(cursorList.toArray(new Cursor[0]));
}
示例2: loadInBackground
import android.database.MergeCursor; //导入依赖的package包/类
@Override
public Cursor loadInBackground() {
Cursor albums = super.loadInBackground();
MatrixCursor allAlbum = new MatrixCursor(COLUMNS);
int totalCount = 0;
String allAlbumCoverPath = "";
if (albums != null) {
while (albums.moveToNext()) {
totalCount += albums.getInt(albums.getColumnIndex(COLUMN_COUNT));
}
if (albums.moveToFirst()) {
allAlbumCoverPath = albums.getString(albums.getColumnIndex(MediaStore.MediaColumns.DATA));
}
}
allAlbum.addRow(new String[]{Album.ALBUM_ID_ALL, Album.ALBUM_ID_ALL, Album.ALBUM_NAME_ALL, allAlbumCoverPath,
String.valueOf(totalCount)});
return new MergeCursor(new Cursor[]{allAlbum, albums});
}
示例3: mergeDates
import android.database.MergeCursor; //导入依赖的package包/类
private MergeCursor mergeDates(long nextId, Map<Long, MatrixCursor> agenda) {
List<Cursor> allCursors = new ArrayList<>();
for (long dateMilli: agenda.keySet()) {
DateTime date = new DateTime(dateMilli);
MatrixCursor dateCursor = new MatrixCursor(Columns.AGENDA_SEPARATOR_COLS);
MatrixCursor.RowBuilder dateRow = dateCursor.newRow();
dateRow.add(nextId++);
dateRow.add(userTimeFormatter.formatDate(AgendaUtils.buildOrgDateTimeFromDate(date, null)));
dateRow.add(1); // Separator
allCursors.add(dateCursor);
allCursors.add(agenda.get(dateMilli));
}
return new MergeCursor(allCursors.toArray(new Cursor[allCursors.size()]));
}
示例4: loadInBackground
import android.database.MergeCursor; //导入依赖的package包/类
@Override
public Cursor loadInBackground() {
Cursor albums = super.loadInBackground();
MatrixCursor allAlbum = new MatrixCursor(COLUMNS);
int totalCount = 0;
while (albums.moveToNext()) {
totalCount += albums.getInt(albums.getColumnIndex(COLUMN_COUNT));
}
String allAlbumCoverPath;
if (albums.moveToFirst()) {
allAlbumCoverPath = albums.getString(albums.getColumnIndex(MediaStore.MediaColumns.DATA));
} else {
allAlbumCoverPath = "";
}
allAlbum.addRow(new String[]{Album.ALBUM_ID_ALL, Album.ALBUM_ID_ALL, Album.ALBUM_NAME_ALL, allAlbumCoverPath,
String.valueOf(totalCount)});
return new MergeCursor(new Cursor[]{allAlbum, albums});
}
示例5: o
import android.database.MergeCursor; //导入依赖的package包/类
public final Cursor o()
{
hqr localhqr = new hqr(lna.a);
Object[] arrayOfObject = new Object[2];
arrayOfObject[0] = Integer.valueOf(0);
arrayOfObject[1] = Integer.valueOf(2);
localhqr.a(arrayOfObject);
Cursor localCursor1 = this.t.a(this.s, lnc.c, this.r);
if (localCursor1 != null) {
localCursor1.registerContentObserver(this.u);
}
if ((localCursor1 == null) || (localCursor1.getCount() == 0)) {
return localCursor1;
}
Cursor localCursor2 = this.t.b(this.s, lnd.a, this.r);
if (localCursor2 != null) {
localCursor2.registerContentObserver(this.u);
}
return new MergeCursor(new Cursor[] { localhqr, localCursor1, localCursor2 });
}
示例6: o
import android.database.MergeCursor; //导入依赖的package包/类
public final Cursor o()
{
Cursor localCursor = DreamSettingsActivity.a(this.l, aau.ft);
isv[] arrayOfisv = efj.c(this.l, 0, 5);
MatrixCursor localMatrixCursor = new MatrixCursor(DreamSettingsActivity.d);
Object[] arrayOfObject = new Object[DreamSettingsActivity.d.length];
int i = arrayOfisv.length;
for (int j = 0; j < i; j++)
{
isv localisv = arrayOfisv[j];
Arrays.fill(arrayOfObject, null);
arrayOfObject[0] = Integer.valueOf(0);
arrayOfObject[3] = Integer.valueOf(1);
arrayOfObject[1] = localisv.a;
arrayOfObject[2] = localisv.b;
localMatrixCursor.addRow(arrayOfObject);
}
return new MergeCursor(new Cursor[] { localCursor, localMatrixCursor });
}
示例7: testIteratorWithMergeCursor
import android.database.MergeCursor; //导入依赖的package包/类
public void testIteratorWithMergeCursor() {
MatrixCursor cursor1 = new MatrixCursor(new String[]{"_id"});
cursor1.addRow(new Object[]{1L});
MatrixCursor cursor2 = new MatrixCursor(new String[]{"_id", "stringProperty"});
cursor2.addRow(new Object[]{2L, "Test"});
MergeCursor mergeCursor = new MergeCursor(new Cursor[]{cursor1, cursor2});
mergeCursor.moveToPosition(-1);
QueryResultIterable<TestEntity> iterable = new QueryResultIterable<TestEntity>(mergeCursor, mStore.getEntityConverter(TestEntity.class));
TestEntity te = iterable.get();
assertEquals(1L, te._id.longValue());
assertEquals(null, te.stringProperty);
mergeCursor.moveToPosition(1);
iterable = new QueryResultIterable<TestEntity>(mergeCursor, mStore.getEntityConverter(TestEntity.class));
te = iterable.get();
assertEquals(2L, te._id.longValue());
assertEquals("Test", te.stringProperty);
}
示例8: loadInBackground
import android.database.MergeCursor; //导入依赖的package包/类
@Override
public Cursor loadInBackground() {
ContactsDatabase contactsDatabase = DatabaseFactory.getContactsDatabase(getContext());
ArrayList<Cursor> cursorList = new ArrayList<>(3);
cursorList.add(contactsDatabase.querySilenceContacts(filter));
if (includeSmsContacts) {
cursorList.add(contactsDatabase.querySystemContacts(filter));
}
if (!TextUtils.isEmpty(filter) && NumberUtil.isValidSmsOrEmail(filter)) {
cursorList.add(contactsDatabase.getNewNumberCursor(filter));
}
return new MergeCursor(cursorList.toArray(new Cursor[0]));
}
示例9: getUnarchivedConversationList
import android.database.MergeCursor; //导入依赖的package包/类
private Cursor getUnarchivedConversationList() {
List<Cursor> cursorList = new LinkedList<>();
cursorList.add(DatabaseFactory.getThreadDatabase(context).getConversationList());
int archivedCount = DatabaseFactory.getThreadDatabase(context)
.getArchivedConversationListCount();
if (archivedCount > 0) {
MatrixCursor switchToArchiveCursor = new MatrixCursor(new String[] {
ThreadDatabase.ID, ThreadDatabase.DATE, ThreadDatabase.MESSAGE_COUNT,
ThreadDatabase.RECIPIENT_IDS, ThreadDatabase.SNIPPET, ThreadDatabase.READ,
ThreadDatabase.TYPE, ThreadDatabase.SNIPPET_TYPE, ThreadDatabase.SNIPPET_URI,
ThreadDatabase.ARCHIVED, ThreadDatabase.STATUS, ThreadDatabase.LAST_SEEN}, 1);
switchToArchiveCursor.addRow(new Object[] {-1L, System.currentTimeMillis(), archivedCount,
"-1", null, 1, ThreadDatabase.DistributionTypes.ARCHIVE,
0, null, 0, -1, 0});
cursorList.add(switchToArchiveCursor);
}
return new MergeCursor(cursorList.toArray(new Cursor[0]));
}
示例10: getAllMediasCursor
import android.database.MergeCursor; //导入依赖的package包/类
Cursor getAllMediasCursor() {
String where = null;
final SharedPreferences prefs = getDefaultSharedPreferences(PBApplication.getApp());
final Set<String> bucketIds = prefs.getStringSet(PBConstants.PREF_PICTURE_FOLDER_LIST, null);
if (bucketIds != null && !bucketIds.isEmpty()) {
final String bucketString = TextUtils.join(", ", bucketIds);
where = "bucket_id in (" + bucketString + ")";
}
final boolean backupVideos = prefs.getBoolean(PBConstants.PREF_MEDIA_BACKUP_VIDEO, false);
final ContentResolver cr = PBApplication.getApp().getContentResolver();
final Cursor[] cursors = new Cursor[backupVideos ? 2 : 1];
cursors[0] = cr.query(imagesUri, imagesProjection, where, null, DATE_ADDED_DESC);
if (backupVideos) {
cursors[1] = cr.query(videosUri, imagesProjection, where, null, DATE_ADDED_DESC);
}
if (cursors[0] == null) {
Log.d(LOG_TAG, "Media cursor is null.");
return null;
}
return new MergeCursor(cursors);
}
示例11: onPostExecute
import android.database.MergeCursor; //导入依赖的package包/类
@Override
protected void onPostExecute(Cursor cursor) {
super.onPostExecute(cursor);
// Reset as late as possible, otherwise the idiotic "empty view" is shown
if (params.reset) {
log.fine("Reset flag, clearing and closing existing cursors");
cursors.clear();
Cursor current = getWrappedAdapter().swapCursor(null);
if (current != null) current.close();
requiresRefresh.set(false);
}
if (cursor != null) {
log.fine("Merging query result cursor with existing cursors");
cursors.add(cursor);
getWrappedAdapter().swapCursor(new MergeCursor(cursors.toArray(new Cursor[cursors.size()])));
}
onPostExecuteQuery(params);
}
示例12: testCloseCursors
import android.database.MergeCursor; //导入依赖的package包/类
@Test
public void testCloseCursors() throws Exception {
Cursor[] cursors = new Cursor[2];
cursors[0] = dbCursor1;
cursors[1] = dbCursor2;
cursor = new MergeCursor( cursors );
assertThat(cursor.isClosed()).isFalse();
assertThat(dbCursor1.isClosed()).isFalse();
assertThat(dbCursor2.isClosed()).isFalse();
cursor.close();
assertThat(cursor.isClosed()).isTrue();
assertThat(dbCursor1.isClosed()).isTrue();
assertThat(dbCursor2.isClosed()).isTrue();
}
示例13: loadInBackground
import android.database.MergeCursor; //导入依赖的package包/类
@Override
public Cursor loadInBackground() {
// First load the profile, if enabled.
List<Cursor> cursors = new ArrayList<Cursor>();
if (mLoadProfile) {
cursors.add(loadProfile());
}
final Cursor contactsCursor = super.loadInBackground();
cursors.add(contactsCursor);
return new MergeCursor(cursors.toArray(new Cursor[cursors.size()])) {
@Override
public Bundle getExtras() {
// Need to get the extras from the contacts cursor.
return contactsCursor.getExtras();
}
};
}
示例14: createMergedCursor
import android.database.MergeCursor; //导入依赖的package包/类
/** Creates the merged cursor representing the data to show in the call log. */
/* TODO @GuardedBy("this") */
private Cursor createMergedCursor() {
try {
final boolean hasNewCalls = mNewCallsCursor.getCount() != 0;
final boolean hasOldCalls = mOldCallsCursor.getCount() != 0;
if (!hasNewCalls) {
Closeables.closeQuietly(mNewCallsCursor); // Return only the old calls, without the header.
return mOldCallsCursor;
}
if (!hasOldCalls) {
Closeables.closeQuietly(mOldCallsCursor); // Return only the new calls.
return new MergeCursor(new Cursor[]{ createNewCallsHeaderCursor(), mNewCallsCursor });
}
return new MergeCursor(new Cursor[]{
createNewCallsHeaderCursor(), mNewCallsCursor,
createOldCallsHeaderCursor(), mOldCallsCursor});
} finally { // Any cursor still open is now owned, directly or indirectly, by the caller.
mNewCallsCursor = null;
mOldCallsCursor = null;
}
}
示例15: getCursor
import android.database.MergeCursor; //导入依赖的package包/类
public static synchronized Cursor getCursor(final Context context, boolean isStranger) {
if (isStranger) {
return getDB(context).query(RandoDBHelper.RandoTable.NAME,
null, RandoDBHelper.RandoTable.COLUMN_RANDO_STATUS
+ " = '" + Rando.Status.IN.name() + "'", null, null, null, RandoDBHelper.RandoTable.COLUMN_USER_RANDO_DATE + " DESC", null);
}
else {
// randos to upload
Cursor cursor1 = getDB(context).query(RandoDBHelper.RandoUploadTable.NAME,
RandoDBHelper.RandoUploadTable.ALL_COLUMNS, null, null, null, null, RandoDBHelper.RandoUploadTable.COLUMN_DATE + " " + "DESC", null);
// uploaded randos
Cursor cursor2 = getDB(context).query(RandoDBHelper.RandoTable.NAME,
null, RandoDBHelper.RandoTable.COLUMN_RANDO_STATUS
+ " = '" + Rando.Status.OUT.name() + "'", null, null, null, RandoDBHelper.RandoTable.COLUMN_USER_RANDO_DATE + " DESC", null);
return new MergeCursor(new Cursor[] {cursor1, cursor2});
}
}