當前位置: 首頁>>代碼示例>>Java>>正文


Java MergeCursor類代碼示例

本文整理匯總了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]));
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:25,代碼來源:ConversationListLoader.java

示例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});
}
 
開發者ID:sathishmscict,項目名稱:Matisse-Image-and-Video-Selector,代碼行數:20,代碼來源:AlbumLoader.java

示例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()]));
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:17,代碼來源:AgendaFragment.java

示例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});
}
 
開發者ID:GitPhoenix,項目名稱:VanGogh,代碼行數:20,代碼來源:AlbumLoader.java

示例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 });
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:21,代碼來源:bvb.java

示例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 });
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:20,代碼來源:dky.java

示例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);
}
 
開發者ID:electrolobzik,項目名稱:cupboard,代碼行數:18,代碼來源:CupboardTest.java

示例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]));
}
 
開發者ID:SilenceIM,項目名稱:Silence,代碼行數:18,代碼來源:ContactsCursorLoader.java

示例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]));
}
 
開發者ID:SilenceIM,項目名稱:Silence,代碼行數:24,代碼來源:ConversationListLoader.java

示例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);
}
 
開發者ID:PhotoBackup,項目名稱:client-android,代碼行數:24,代碼來源:PBMediaStore.java

示例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);
}
 
開發者ID:4thline,項目名稱:feeds,代碼行數:22,代碼來源:PagingCursorAdapterWrapper.java

示例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();
}
 
開發者ID:qx,項目名稱:FullRobolectricTestSample,代碼行數:18,代碼來源:MergeCursorTest.java

示例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();
        }
    };
}
 
開發者ID:SilentCircle,項目名稱:silent-contacts-android,代碼行數:18,代碼來源:ProfileAndContactsLoader.java

示例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;
    }
}
 
開發者ID:SilentCircle,項目名稱:silent-contacts-android,代碼行數:25,代碼來源:ScCallLogQueryHandler.java

示例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});
        }

    }
 
開發者ID:RandoApp,項目名稱:Rando-android,代碼行數:23,代碼來源:RandoDAO.java


注:本文中的android.database.MergeCursor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。