Fix extensions installer on old Android versions. Fix deadlock on devices with 1-2 cores

This commit is contained in:
inorichi
2018-02-06 11:42:38 +01:00
parent 02e187f066
commit 636c027298
2 changed files with 40 additions and 14 deletions

View File

@ -11,7 +11,8 @@ import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.extension.ExtensionManager
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.source.SourceManager
import kotlinx.coroutines.experimental.async
import rx.Observable
import rx.schedulers.Schedulers
import uy.kohesive.injekt.api.*
class AppModule(val app: Application) : InjektModule {
@ -42,16 +43,20 @@ class AppModule(val app: Application) : InjektModule {
// Asynchronously init expensive components for a faster cold start
async { get<PreferencesHelper>() }
rxAsync { get<PreferencesHelper>() }
async { get<NetworkHelper>() }
rxAsync { get<NetworkHelper>() }
async { get<SourceManager>() }
rxAsync { get<SourceManager>() }
async { get<DatabaseHelper>() }
rxAsync { get<DatabaseHelper>() }
async { get<DownloadManager>() }
rxAsync { get<DownloadManager>() }
}
}
private fun rxAsync(block: () -> Unit) {
Observable.fromCallable { block() }.subscribeOn(Schedulers.computation()).subscribe()
}
}