forked from upstream-mirrors/quik
Upgrade Realm, use new query predicates for loading conversations
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.realm:realm-gradle-plugin:4.1.1"
|
||||
classpath "io.realm:realm-gradle-plugin:4.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -56,14 +56,14 @@ dependencies {
|
||||
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
||||
compile "io.reactivex.rxjava2:rxjava:2.1.4"
|
||||
compile 'io.reactivex.rxjava2:rxkotlin:2.1.0'
|
||||
compile 'io.realm:android-adapters:2.1.0'
|
||||
compile('io.realm:android-adapters:2.1.0') { transitive = false }
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
||||
compile project(":google-mms")
|
||||
kapt "android.arch.lifecycle:compiler:1.0.0"
|
||||
kapt 'com.github.bumptech.glide:compiler:4.3.0'
|
||||
kapt "com.google.dagger:dagger-compiler:2.11"
|
||||
kapt 'io.realm:realm-annotations:4.1.1'
|
||||
kapt 'io.realm:realm-annotations-processor:4.1.1'
|
||||
kapt 'io.realm:realm-annotations:4.3.1'
|
||||
kapt 'io.realm:realm-annotations-processor:4.3.1'
|
||||
testCompile 'com.android.support.test:runner:1.0.1'
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||
|
||||
@@ -65,14 +65,10 @@ class MessageRepository @Inject constructor(
|
||||
.filter { it.isLoaded }
|
||||
.map { realm.copyFromRealm(it) }
|
||||
|
||||
// Adding the #distinct() call makes this call approx 20x slower
|
||||
// With ~70,000 messages on a Google Pixel, it goes from 15ms -> 300ms
|
||||
// This should be fixed by using Realm 4.3, but that breaks the build
|
||||
// Will fix
|
||||
val messageFlowable = realm.where(Message::class.java)
|
||||
.findAllSortedAsync("date", Sort.DESCENDING)
|
||||
.where()
|
||||
.distinctAsync("threadId")
|
||||
.sort("date", Sort.DESCENDING)
|
||||
.distinctValues("threadId")
|
||||
.findAllAsync()
|
||||
.asFlowable()
|
||||
.filter { it.isLoaded }
|
||||
.map { realm.copyFromRealm(it) }
|
||||
|
||||
@@ -30,12 +30,12 @@ import data.model.MenuItem
|
||||
import data.model.SyncLog
|
||||
import data.repository.MessageRepository
|
||||
import interactor.*
|
||||
import presentation.Navigator
|
||||
import presentation.common.base.QkViewModel
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
import io.realm.Realm
|
||||
import presentation.Navigator
|
||||
import presentation.common.base.QkViewModel
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -77,7 +77,7 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
||||
.distinctUntilChanged()
|
||||
.subscribe { syncing -> newState { it.copy(syncing = syncing) } }
|
||||
|
||||
newState { it.copy(page = Inbox(data = messageRepo.getConversations())) }
|
||||
newState { it.copy(page = Inbox(data = conversations)) }
|
||||
|
||||
val isDefaultSms = Telephony.Sms.getDefaultSmsPackage(context) != context.packageName
|
||||
val hasSmsPermission = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED
|
||||
|
||||
Reference in New Issue
Block a user