Search in sources :

Example 1 with StickerRecordReader

use of org.thoughtcrime.securesms.database.StickerDatabase.StickerRecordReader in project Signal-Android by WhisperSystems.

the class StickerSearchRepository method searchByEmoji.

public void searchByEmoji(@NonNull String emoji, @NonNull Callback<List<StickerRecord>> callback) {
    SignalExecutors.BOUNDED.execute(() -> {
        String searchEmoji = EmojiUtil.getCanonicalRepresentation(emoji);
        List<StickerRecord> out = new ArrayList<>();
        Set<String> possible = EmojiUtil.getAllRepresentations(searchEmoji);
        for (String candidate : possible) {
            try (StickerRecordReader reader = new StickerRecordReader(stickerDatabase.getStickersByEmoji(candidate))) {
                StickerRecord record = null;
                while ((record = reader.getNext()) != null) {
                    out.add(record);
                }
            }
        }
        callback.onResult(out);
    });
}
Also used : ArrayList(java.util.ArrayList) StickerRecord(org.thoughtcrime.securesms.database.model.StickerRecord) StickerRecordReader(org.thoughtcrime.securesms.database.StickerDatabase.StickerRecordReader)

Example 2 with StickerRecordReader

use of org.thoughtcrime.securesms.database.StickerDatabase.StickerRecordReader in project Signal-Android by signalapp.

the class StickerSearchRepository method searchByEmoji.

public void searchByEmoji(@NonNull String emoji, @NonNull Callback<List<StickerRecord>> callback) {
    SignalExecutors.BOUNDED.execute(() -> {
        String searchEmoji = EmojiUtil.getCanonicalRepresentation(emoji);
        List<StickerRecord> out = new ArrayList<>();
        Set<String> possible = EmojiUtil.getAllRepresentations(searchEmoji);
        for (String candidate : possible) {
            try (StickerRecordReader reader = new StickerRecordReader(stickerDatabase.getStickersByEmoji(candidate))) {
                StickerRecord record = null;
                while ((record = reader.getNext()) != null) {
                    out.add(record);
                }
            }
        }
        callback.onResult(out);
    });
}
Also used : ArrayList(java.util.ArrayList) StickerRecord(org.thoughtcrime.securesms.database.model.StickerRecord) StickerRecordReader(org.thoughtcrime.securesms.database.StickerDatabase.StickerRecordReader)

Aggregations

ArrayList (java.util.ArrayList)2 StickerRecordReader (org.thoughtcrime.securesms.database.StickerDatabase.StickerRecordReader)2 StickerRecord (org.thoughtcrime.securesms.database.model.StickerRecord)2