From fda48b3b9ef7ef043f906475418b03632e23c93f Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Thu, 16 Feb 2017 19:19:04 +0800 Subject: [PATCH] fixed rawQuery --- .../extension/ContentResolverExtensions.kt | 2 +- .../twidere/provider/TwidereDataProvider.kt | 15 +++++++++++---- .../twidere/util/ContentNotificationManager.kt | 4 ++-- .../org/mariotaku/twidere/util/DataStoreUtils.kt | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/ContentResolverExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/ContentResolverExtensions.kt index 51e1cb1d1..f1f80ed45 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/ContentResolverExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/ContentResolverExtensions.kt @@ -28,6 +28,6 @@ import org.mariotaku.twidere.provider.TwidereDataStore @SuppressLint("Recycle") fun ContentResolver.rawQuery(sql: String, selectionArgs: Array?): 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) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/provider/TwidereDataProvider.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/provider/TwidereDataProvider.kt index 7ff59d26a..9e50d800b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/provider/TwidereDataProvider.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/provider/TwidereDataProvider.kt @@ -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 } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/ContentNotificationManager.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/ContentNotificationManager.kt index 60420a469..b7306ef6b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/ContentNotificationManager.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/ContentNotificationManager.kt @@ -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 diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/DataStoreUtils.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/DataStoreUtils.kt index d1496a955..5f9ac5f3d 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/DataStoreUtils.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/DataStoreUtils.kt @@ -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) {