fixed rawQuery

This commit is contained in:
Mariotaku Lee 2017-02-16 19:19:04 +08:00
parent 251b358918
commit fda48b3b9e
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
4 changed files with 15 additions and 8 deletions

View File

@ -28,6 +28,6 @@ import org.mariotaku.twidere.provider.TwidereDataStore
@SuppressLint("Recycle")
fun ContentResolver.rawQuery(sql: String, selectionArgs: Array<String>?): Cursor {
val rawUri = Uri.withAppendedPath(TwidereDataStore.CONTENT_URI_RAW_QUERY, sql)
return query(rawUri, selectionArgs, null, null, null)
return query(rawUri, null, null, selectionArgs, null)
}

View File

@ -521,7 +521,7 @@ class TwidereDataProvider : ContentProvider(), LazyLoadCallback {
DataStoreUtils.getAccountKeys(context))
prefs.filter(AccountPreferences::isHomeTimelineNotificationEnabled).forEach {
val positionTag = getPositionTag(CustomTabType.HOME_TIMELINE, it.accountKey)
contentNotificationManager.showTimelineNotification(it, positionTag)
contentNotificationManager.showTimeline(it, positionTag)
}
notifyUnreadCountChanged(NOTIFICATION_ID_HOME_TIMELINE)
}
@ -531,7 +531,7 @@ class TwidereDataProvider : ContentProvider(), LazyLoadCallback {
val prefs = AccountPreferences.getNotificationEnabledPreferences(context,
DataStoreUtils.getAccountKeys(context))
prefs.filter(AccountPreferences::isInteractionsNotificationEnabled).forEach {
contentNotificationManager.showInteractionsNotification(it, getPositionTag(ReadPositionTag.ACTIVITIES_ABOUT_ME,
contentNotificationManager.showInteractions(it, getPositionTag(ReadPositionTag.ACTIVITIES_ABOUT_ME,
it.accountKey))
}
notifyUnreadCountChanged(NOTIFICATION_ID_INTERACTIONS_TIMELINE)
@ -562,8 +562,15 @@ class TwidereDataProvider : ContentProvider(), LazyLoadCallback {
private fun getConflictAlgorithm(tableId: Int): Int {
when (tableId) {
TABLE_ID_CACHED_HASHTAGS, TABLE_ID_CACHED_STATUSES, TABLE_ID_CACHED_USERS, TABLE_ID_CACHED_RELATIONSHIPS, TABLE_ID_SEARCH_HISTORY, TABLE_ID_MESSAGES, TABLE_ID_MESSAGES_CONVERSATIONS -> return SQLiteDatabase.CONFLICT_REPLACE
TABLE_ID_FILTERED_USERS, TABLE_ID_FILTERED_KEYWORDS, TABLE_ID_FILTERED_SOURCES, TABLE_ID_FILTERED_LINKS -> return SQLiteDatabase.CONFLICT_IGNORE
TABLE_ID_CACHED_HASHTAGS, TABLE_ID_CACHED_STATUSES, TABLE_ID_CACHED_USERS,
TABLE_ID_CACHED_RELATIONSHIPS, TABLE_ID_SEARCH_HISTORY, TABLE_ID_MESSAGES,
TABLE_ID_MESSAGES_CONVERSATIONS -> {
return SQLiteDatabase.CONFLICT_REPLACE
}
TABLE_ID_FILTERED_USERS, TABLE_ID_FILTERED_KEYWORDS, TABLE_ID_FILTERED_SOURCES,
TABLE_ID_FILTERED_LINKS -> {
return SQLiteDatabase.CONFLICT_IGNORE
}
}
return SQLiteDatabase.CONFLICT_NONE
}

View File

@ -65,7 +65,7 @@ class ContentNotificationManager(
private var nameFirst: Boolean = false
private var useStarForLikes: Boolean = false
fun showInteractionsNotification(pref: AccountPreferences, position: Long) {
fun showInteractions(pref: AccountPreferences, position: Long) {
val cr = context.contentResolver
val accountKey = pref.accountKey
val where = Expression.and(
@ -195,7 +195,7 @@ class ContentNotificationManager(
return !activityTracker.isHomeActivityStarted
}
fun showTimelineNotification(pref: AccountPreferences, position: Long) {
fun showTimeline(pref: AccountPreferences, position: Long) {
val accountKey = pref.accountKey
val resources = context.resources
val nm = notificationManager

View File

@ -675,7 +675,7 @@ object DataStoreUtils {
if (sortExpression != null) {
builder.orderBy(sortExpression)
}
resolver.rawQuery(builder.buildSQL(), bindingArgs)?.useCursor { cur ->
resolver.rawQuery(builder.buildSQL(), bindingArgs).useCursor { cur ->
cur.moveToFirst()
val colIdx = creator.newIndex(cur)
while (!cur.isAfterLast) {