use of android.support.annotation.WorkerThread in project k-9 by k9mail.
the class MessageViewInfoExtractor method extractMessageForView.
@WorkerThread
public MessageViewInfo extractMessageForView(Message message, @Nullable MessageCryptoAnnotations annotations) throws MessagingException {
Part rootPart;
CryptoResultAnnotation cryptoResultAnnotation;
List<Part> extraParts;
CryptoMessageParts cryptoMessageParts = MessageCryptoSplitter.split(message, annotations);
if (cryptoMessageParts != null) {
rootPart = cryptoMessageParts.contentPart;
cryptoResultAnnotation = cryptoMessageParts.contentCryptoAnnotation;
extraParts = cryptoMessageParts.extraParts;
} else {
if (annotations != null && !annotations.isEmpty()) {
Timber.e("Got message annotations but no crypto root part!");
}
rootPart = message;
cryptoResultAnnotation = null;
extraParts = null;
}
List<AttachmentViewInfo> attachmentInfos = new ArrayList<>();
ViewableExtractedText viewable = extractViewableAndAttachments(Collections.singletonList(rootPart), attachmentInfos);
List<AttachmentViewInfo> extraAttachmentInfos = new ArrayList<>();
String extraViewableText = null;
if (extraParts != null) {
ViewableExtractedText extraViewable = extractViewableAndAttachments(extraParts, extraAttachmentInfos);
extraViewableText = extraViewable.text;
}
AttachmentResolver attachmentResolver = AttachmentResolver.createFromPart(rootPart);
boolean isMessageIncomplete = !message.isSet(Flag.X_DOWNLOADED_FULL) || MessageExtractor.hasMissingParts(message);
return MessageViewInfo.createWithExtractedContent(message, isMessageIncomplete, rootPart, viewable.html, attachmentInfos, cryptoResultAnnotation, attachmentResolver, extraViewableText, extraAttachmentInfos);
}
use of android.support.annotation.WorkerThread in project materialistic by hidroh.
the class FavoriteManager method insert.
@WorkerThread
private Uri insert(Context context, WebItem story) {
ContentValues cv = new ContentValues();
cv.put(MaterialisticProvider.FavoriteEntry.COLUMN_NAME_ITEM_ID, story.getId());
cv.put(MaterialisticProvider.FavoriteEntry.COLUMN_NAME_URL, story.getUrl());
cv.put(MaterialisticProvider.FavoriteEntry.COLUMN_NAME_TITLE, story.getDisplayedTitle());
cv.put(MaterialisticProvider.FavoriteEntry.COLUMN_NAME_TIME, story instanceof Favorite ? String.valueOf(((Favorite) story).getTime()) : String.valueOf(System.currentTimeMillis()));
return context.getContentResolver().insert(MaterialisticProvider.URI_FAVORITE, cv);
}
use of android.support.annotation.WorkerThread in project Lightning-Browser by anthonycr.
the class HistoryDatabase method findItemsContaining.
@WorkerThread
@NonNull
synchronized List<HistoryItem> findItemsContaining(@Nullable String search) {
List<HistoryItem> itemList = new ArrayList<>(5);
if (search == null) {
return itemList;
}
search = '%' + search + '%';
Cursor cursor = lazyDatabase().query(TABLE_HISTORY, null, KEY_TITLE + " LIKE ? OR " + KEY_URL + " LIKE ?", new String[] { search, search }, null, null, KEY_TIME_VISITED + " DESC", "5");
while (cursor.moveToNext()) {
itemList.add(fromCursor(cursor));
}
cursor.close();
return itemList;
}
use of android.support.annotation.WorkerThread in project Lightning-Browser by anthonycr.
the class HistoryDatabase method getHistoryItem.
@WorkerThread
@Nullable
synchronized String getHistoryItem(@NonNull String url) {
Cursor cursor = lazyDatabase().query(TABLE_HISTORY, new String[] { KEY_ID, KEY_URL, KEY_TITLE }, KEY_URL + " = ?", new String[] { url }, null, null, null, "1");
String m = null;
if (cursor != null) {
cursor.moveToFirst();
m = cursor.getString(0);
cursor.close();
}
return m;
}
use of android.support.annotation.WorkerThread in project Lightning-Browser by anthonycr.
the class HistoryDatabase method getLastHundredItems.
@WorkerThread
@NonNull
synchronized List<HistoryItem> getLastHundredItems() {
List<HistoryItem> itemList = new ArrayList<>(100);
Cursor cursor = lazyDatabase().query(TABLE_HISTORY, null, null, null, null, null, KEY_TIME_VISITED + " DESC", "100");
while (cursor.moveToNext()) {
itemList.add(fromCursor(cursor));
}
cursor.close();
return itemList;
}
Aggregations