use of android.database.Cursor in project Talon-for-Twitter by klinker24.
the class HomeDataSource method getTrimmingCursor.
public synchronized Cursor getTrimmingCursor(int account) {
String where = HomeSQLiteHelper.COLUMN_ACCOUNT + " = " + account;
Cursor cursor;
try {
cursor = database.query(HomeSQLiteHelper.TABLE_HOME, allColumns, where, null, null, null, HomeSQLiteHelper.COLUMN_TWEET_ID + " ASC");
} catch (Exception e) {
open();
cursor = database.query(HomeSQLiteHelper.TABLE_HOME, allColumns, where, null, null, null, HomeSQLiteHelper.COLUMN_TWEET_ID + " ASC");
}
return cursor;
}
use of android.database.Cursor in project Talon-for-Twitter by klinker24.
the class HomeDataSource method getLastIds.
public synchronized long[] getLastIds(int account) {
long[] id = new long[] { 0, 0, 0, 0, 0 };
Cursor cursor;
try {
cursor = getCursor(account);
} catch (Exception e) {
return id;
}
try {
if (cursor.moveToLast()) {
int i = 0;
do {
id[i] = cursor.getLong(cursor.getColumnIndex(MentionsSQLiteHelper.COLUMN_TWEET_ID));
i++;
} while (cursor.moveToPrevious() && i < 5);
}
} catch (Exception e) {
}
if (cursor != null) {
cursor.close();
}
return id;
}
use of android.database.Cursor in project Talon-for-Twitter by klinker24.
the class InteractionsDataSource method getUsers.
public synchronized String getUsers(int account, int position, boolean unread) {
Cursor cursor;
if (unread) {
cursor = getUnreadBackwordCursor(account);
} else {
cursor = getBackwordCursor(account);
}
String users = "";
if (cursor.moveToPosition(position)) {
users = cursor.getString(cursor.getColumnIndex(InteractionsSQLiteHelper.COLUMN_USERS));
}
cursor.close();
return users;
}
use of android.database.Cursor in project Talon-for-Twitter by klinker24.
the class InteractionsDataSource method getUnreadCount.
public synchronized int getUnreadCount(int account) {
Cursor cursor = getUnreadCursor(account);
int count = cursor.getCount();
cursor.close();
return count;
}
use of android.database.Cursor in project Talon-for-Twitter by klinker24.
the class ListDataSource method getCursor.
public synchronized Cursor getCursor(long listId) {
String users = sharedPreferences.getString("muted_users", "");
String rts = sharedPreferences.getString("muted_rts", "");
String hashtags = sharedPreferences.getString("muted_hashtags", "");
String expressions = sharedPreferences.getString("muted_regex", "");
expressions = expressions.replaceAll("'", "''");
String where = ListSQLiteHelper.COLUMN_LIST_ID + " = " + listId;
if (!users.equals("")) {
String[] split = users.split(" ");
for (String s : split) {
where += " AND " + ListSQLiteHelper.COLUMN_SCREEN_NAME + " NOT LIKE '" + s + "'";
}
for (String s : split) {
where += " AND " + ListSQLiteHelper.COLUMN_RETWEETER + " NOT LIKE '" + s + "'";
}
}
if (!hashtags.equals("")) {
String[] split = hashtags.split(" ");
for (String s : split) {
where += " AND " + ListSQLiteHelper.COLUMN_HASHTAGS + " NOT LIKE " + "'%" + s + "%'";
}
}
if (!expressions.equals("")) {
String[] split = expressions.split(" ");
for (String s : split) {
where += " AND " + ListSQLiteHelper.COLUMN_TEXT + " NOT LIKE " + "'%" + s + "%'";
}
}
if (noRetweets) {
where += " AND " + ListSQLiteHelper.COLUMN_RETWEETER + " = '' OR " + ListSQLiteHelper.COLUMN_RETWEETER + " is NULL";
} else if (!rts.equals("")) {
String[] split = rts.split(" ");
for (String s : split) {
where += " AND " + HomeSQLiteHelper.COLUMN_RETWEETER + " NOT LIKE '" + s + "'";
}
}
Cursor cursor;
String sql = "SELECT COUNT(*) FROM " + ListSQLiteHelper.TABLE_HOME + " WHERE " + where;
SQLiteStatement statement;
try {
statement = database.compileStatement(sql);
} catch (Exception e) {
open();
statement = database.compileStatement(sql);
}
long count;
try {
count = statement.simpleQueryForLong();
} catch (Exception e) {
open();
count = statement.simpleQueryForLong();
}
Log.v("talon_database", "list database has " + count + " entries");
if (count > 400) {
try {
cursor = database.query(ListSQLiteHelper.TABLE_HOME, allColumns, where, null, null, null, ListSQLiteHelper.COLUMN_TWEET_ID + " ASC", (count - 400) + "," + 400);
} catch (Exception e) {
open();
cursor = database.query(ListSQLiteHelper.TABLE_HOME, allColumns, where, null, null, null, ListSQLiteHelper.COLUMN_TWEET_ID + " ASC", (count - 400) + "," + 400);
}
} else {
try {
cursor = database.query(ListSQLiteHelper.TABLE_HOME, allColumns, where, null, null, null, ListSQLiteHelper.COLUMN_TWEET_ID + " ASC");
} catch (Exception e) {
open();
cursor = database.query(ListSQLiteHelper.TABLE_HOME, allColumns, where, null, null, null, ListSQLiteHelper.COLUMN_TWEET_ID + " ASC");
}
}
return cursor;
}
Aggregations