Search in sources :

Example 36 with Cursor

use of android.database.Cursor in project Talon-for-Twitter by klinker24.

the class ListDataSource method getLastIds.

public synchronized long[] getLastIds(long listId) {
    long[] id = new long[] { 0, 0, 0, 0, 0 };
    Cursor cursor;
    try {
        cursor = getCursor(listId);
    } catch (Exception e) {
        return id;
    }
    try {
        if (cursor.moveToFirst()) {
            int i = 0;
            do {
                id[i] = cursor.getLong(cursor.getColumnIndex(MentionsSQLiteHelper.COLUMN_TWEET_ID));
            } while (cursor.moveToNext() && i < 5);
        }
    } catch (Exception e) {
    }
    cursor.close();
    return id;
}
Also used : Cursor(android.database.Cursor) SQLException(android.database.SQLException) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException)

Example 37 with Cursor

use of android.database.Cursor in project Talon-for-Twitter by klinker24.

the class MentionsDataSource method tweetExists.

public synchronized boolean tweetExists(long tweetId, int account) {
    Cursor cursor;
    try {
        cursor = database.query(MentionsSQLiteHelper.TABLE_MENTIONS, allColumns, MentionsSQLiteHelper.COLUMN_ACCOUNT + " = " + account + " AND " + MentionsSQLiteHelper.COLUMN_TWEET_ID + " = " + tweetId, null, null, null, MentionsSQLiteHelper.COLUMN_TWEET_ID + " ASC");
    } catch (Exception e) {
        open();
        cursor = database.query(MentionsSQLiteHelper.TABLE_MENTIONS, allColumns, MentionsSQLiteHelper.COLUMN_ACCOUNT + " = " + account + " AND " + MentionsSQLiteHelper.COLUMN_TWEET_ID + " = " + tweetId, null, null, null, MentionsSQLiteHelper.COLUMN_TWEET_ID + " ASC");
    }
    boolean exists = cursor.getCount() > 0;
    cursor.close();
    return exists;
}
Also used : Cursor(android.database.Cursor) SQLException(android.database.SQLException) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException)

Example 38 with Cursor

use of android.database.Cursor in project Talon-for-Twitter by klinker24.

the class MentionsDataSource method getNewestNames.

public synchronized String getNewestNames(int account) {
    Cursor cursor = getUnreadCursor(account);
    String name = "";
    try {
        if (cursor.moveToFirst()) {
            name = cursor.getString(cursor.getColumnIndex(MentionsSQLiteHelper.COLUMN_USERS));
        }
    } catch (Exception e) {
    }
    cursor.close();
    return name;
}
Also used : Cursor(android.database.Cursor) SQLException(android.database.SQLException) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException)

Example 39 with Cursor

use of android.database.Cursor in project Talon-for-Twitter by klinker24.

the class MentionsDataSource method getUnreadCursor.

public synchronized Cursor getUnreadCursor(int account) {
    boolean mutedMentions = sharedPrefs.getBoolean("show_muted_mentions", false);
    String users = sharedPrefs.getString("muted_users", "");
    String hashtags = sharedPrefs.getString("muted_hashtags", "");
    String expressions = sharedPrefs.getString("muted_regex", "");
    expressions = expressions.replaceAll("'", "''");
    String where = MentionsSQLiteHelper.COLUMN_ACCOUNT + " = ? AND " + MentionsSQLiteHelper.COLUMN_UNREAD + " = ?";
    if (!users.equals("") && !mutedMentions) {
        String[] split = users.split(" ");
        for (String s : split) {
            where += " AND " + MentionsSQLiteHelper.COLUMN_SCREEN_NAME + " NOT LIKE '" + s + "'";
        }
    }
    if (!hashtags.equals("")) {
        String[] split = hashtags.split(" ");
        for (String s : split) {
            where += " AND " + MentionsSQLiteHelper.COLUMN_HASHTAGS + " NOT LIKE " + "'%" + s + "%'";
        }
    }
    if (!expressions.equals("")) {
        String[] split = expressions.split("   ");
        for (String s : split) {
            where += " AND " + MentionsSQLiteHelper.COLUMN_TEXT + " NOT LIKE " + "'%" + s + "%'";
        }
    }
    Cursor cursor;
    try {
        cursor = database.query(MentionsSQLiteHelper.TABLE_MENTIONS, allColumns, where, new String[] { account + "", "1" }, null, null, MentionsSQLiteHelper.COLUMN_TWEET_ID + " ASC");
    } catch (Exception e) {
        open();
        cursor = database.query(MentionsSQLiteHelper.TABLE_MENTIONS, allColumns, where, new String[] { account + "", "1" }, null, null, MentionsSQLiteHelper.COLUMN_TWEET_ID + " ASC");
    }
    return cursor;
}
Also used : Cursor(android.database.Cursor) SQLException(android.database.SQLException) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException)

Example 40 with Cursor

use of android.database.Cursor in project Talon-for-Twitter by klinker24.

the class MentionsDataSource method getTrimmingCursor.

public synchronized Cursor getTrimmingCursor(int account) {
    String where = MentionsSQLiteHelper.COLUMN_ACCOUNT + " = " + account;
    Cursor cursor;
    try {
        cursor = database.query(MentionsSQLiteHelper.TABLE_MENTIONS, allColumns, where, null, null, null, MentionsSQLiteHelper.COLUMN_TWEET_ID + " ASC");
    } catch (Exception e) {
        open();
        cursor = database.query(MentionsSQLiteHelper.TABLE_MENTIONS, allColumns, where, null, null, null, MentionsSQLiteHelper.COLUMN_TWEET_ID + " ASC");
    }
    return cursor;
}
Also used : Cursor(android.database.Cursor) SQLException(android.database.SQLException) SQLiteDatabaseLockedException(android.database.sqlite.SQLiteDatabaseLockedException)

Aggregations

Cursor (android.database.Cursor)4002 ArrayList (java.util.ArrayList)547 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)527 Uri (android.net.Uri)467 ContentValues (android.content.ContentValues)334 ContentResolver (android.content.ContentResolver)193 Test (org.junit.Test)183 RemoteException (android.os.RemoteException)182 File (java.io.File)170 IOException (java.io.IOException)159 MatrixCursor (android.database.MatrixCursor)154 Intent (android.content.Intent)140 SQLException (android.database.SQLException)126 MediumTest (android.test.suitebuilder.annotation.MediumTest)116 HashMap (java.util.HashMap)108 SQLiteException (android.database.sqlite.SQLiteException)94 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)93 SQLiteCursor (android.database.sqlite.SQLiteCursor)88 Query (android.app.DownloadManager.Query)76 MergeCursor (android.database.MergeCursor)75