Search in sources :

Example 1 with ConversationReader

use of org.thoughtcrime.securesms.conversationlist.model.ConversationReader in project Signal-Android by WhisperSystems.

the class ConversationListDataSource method load.

@Override
@NonNull
public List<Conversation> load(int start, int length, @NonNull CancellationSignal cancellationSignal) {
    Stopwatch stopwatch = new Stopwatch("load(" + start + ", " + length + "), " + getClass().getSimpleName());
    List<Conversation> conversations = new ArrayList<>(length);
    List<Recipient> recipients = new LinkedList<>();
    try (ConversationReader reader = new ConversationReader(getCursor(start, length))) {
        ThreadRecord record;
        while ((record = reader.getNext()) != null && !cancellationSignal.isCanceled()) {
            conversations.add(new Conversation(record));
            recipients.add(record.getRecipient());
        }
    }
    stopwatch.split("cursor");
    ApplicationDependencies.getRecipientCache().addToCache(recipients);
    stopwatch.split("cache-recipients");
    stopwatch.stop(TAG);
    return conversations;
}
Also used : ConversationReader(org.thoughtcrime.securesms.conversationlist.model.ConversationReader) Stopwatch(org.thoughtcrime.securesms.util.Stopwatch) ArrayList(java.util.ArrayList) ThreadRecord(org.thoughtcrime.securesms.database.model.ThreadRecord) Conversation(org.thoughtcrime.securesms.conversationlist.model.Conversation) Recipient(org.thoughtcrime.securesms.recipients.Recipient) LinkedList(java.util.LinkedList) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 Conversation (org.thoughtcrime.securesms.conversationlist.model.Conversation)1 ConversationReader (org.thoughtcrime.securesms.conversationlist.model.ConversationReader)1 ThreadRecord (org.thoughtcrime.securesms.database.model.ThreadRecord)1 Recipient (org.thoughtcrime.securesms.recipients.Recipient)1 Stopwatch (org.thoughtcrime.securesms.util.Stopwatch)1