Search in sources :

Example 1 with WorkerThread

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);
}
Also used : CryptoMessageParts(com.fsck.k9.ui.crypto.MessageCryptoSplitter.CryptoMessageParts) Part(com.fsck.k9.mail.Part) ArrayList(java.util.ArrayList) WorkerThread(android.support.annotation.WorkerThread)

Example 2 with WorkerThread

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);
}
Also used : ContentValues(android.content.ContentValues) WorkerThread(android.support.annotation.WorkerThread)

Example 3 with WorkerThread

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;
}
Also used : HistoryItem(acr.browser.lightning.database.HistoryItem) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) WorkerThread(android.support.annotation.WorkerThread) NonNull(android.support.annotation.NonNull)

Example 4 with WorkerThread

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;
}
Also used : Cursor(android.database.Cursor) WorkerThread(android.support.annotation.WorkerThread) Nullable(android.support.annotation.Nullable)

Example 5 with WorkerThread

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;
}
Also used : HistoryItem(acr.browser.lightning.database.HistoryItem) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) WorkerThread(android.support.annotation.WorkerThread) NonNull(android.support.annotation.NonNull)

Aggregations

WorkerThread (android.support.annotation.WorkerThread)152 Cursor (android.database.Cursor)37 ArrayList (java.util.ArrayList)36 NonNull (android.support.annotation.NonNull)34 File (java.io.File)20 HashMap (java.util.HashMap)17 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)15 StorIOException (com.pushtorefresh.storio.StorIOException)15 IOException (java.io.IOException)13 ContentValues (android.content.ContentValues)11 Resources (android.content.res.Resources)10 Bitmap (android.graphics.Bitmap)10 Context (android.content.Context)8 Intent (android.content.Intent)7 SharedPreferences (android.content.SharedPreferences)7 Uri (android.net.Uri)7 Nullable (android.support.annotation.Nullable)7 VisibleForTesting (android.support.annotation.VisibleForTesting)7 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)6 Tile (com.android.settingslib.drawer.Tile)6