Search in sources :

Example 51 with WorkerThread

use of android.support.annotation.WorkerThread in project Lightning-Browser by anthonycr.

the class HistoryDatabase method addHistoryItem.

@WorkerThread
private synchronized void addHistoryItem(@NonNull HistoryItem item) {
    ContentValues values = new ContentValues();
    values.put(KEY_URL, item.getUrl());
    values.put(KEY_TITLE, item.getTitle());
    values.put(KEY_TIME_VISITED, System.currentTimeMillis());
    lazyDatabase().insert(TABLE_HISTORY, null, values);
}
Also used : ContentValues(android.content.ContentValues) WorkerThread(android.support.annotation.WorkerThread)

Example 52 with WorkerThread

use of android.support.annotation.WorkerThread in project Lightning-Browser by anthonycr.

the class HistoryDatabase method getAllHistoryItems.

@WorkerThread
@NonNull
synchronized List<HistoryItem> getAllHistoryItems() {
    List<HistoryItem> itemList = new ArrayList<>();
    Cursor cursor = lazyDatabase().query(TABLE_HISTORY, null, null, null, null, null, KEY_TIME_VISITED + " DESC");
    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)52 NonNull (android.support.annotation.NonNull)21 Cursor (android.database.Cursor)17 StorIOException (com.pushtorefresh.storio.StorIOException)15 File (java.io.File)11 ArrayList (java.util.ArrayList)11 Uri (android.net.Uri)8 ContentValues (android.content.ContentValues)6 Nullable (android.support.annotation.Nullable)6 StorIOSQLite (com.pushtorefresh.storio.sqlite.StorIOSQLite)6 HashMap (java.util.HashMap)6 HistoryItem (acr.browser.lightning.database.HistoryItem)5 IOException (java.io.IOException)5 FileInputStream (java.io.FileInputStream)4 Intent (android.content.Intent)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)3 FileNotFoundException (java.io.FileNotFoundException)3 InputStream (java.io.InputStream)3 SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)3 ContentUris (android.content.ContentUris)2