fix workmanager crashing because of async initialization (#2003)

This commit is contained in:
Konrad Pozniak 2020-12-01 07:39:30 +01:00 committed by GitHub
parent 9793035a3d
commit a9337bcb78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 12 deletions

View File

@ -29,11 +29,9 @@ import com.keylesspalace.tusky.util.EmojiCompatFont
import com.keylesspalace.tusky.util.LocaleManager
import com.keylesspalace.tusky.util.ThemeUtils
import com.uber.autodispose.AutoDisposePlugins
import dagger.Lazy
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector
import io.reactivex.plugins.RxJavaPlugins
import io.reactivex.schedulers.Schedulers
import org.conscrypt.Conscrypt
import java.security.Security
import javax.inject.Inject
@ -44,7 +42,7 @@ class TuskyApplication : Application(), HasAndroidInjector {
lateinit var androidInjector: DispatchingAndroidInjector<Any>
@Inject
lateinit var notificationWorkerFactory: Lazy<NotificationWorkerFactory>
lateinit var notificationWorkerFactory: NotificationWorkerFactory
override fun onCreate() {
// Uncomment me to get StrictMode violation logs
@ -82,15 +80,12 @@ class TuskyApplication : Application(), HasAndroidInjector {
Log.w("RxJava", "undeliverable exception", it)
}
// This will initialize the whole network stack and cache so we don't wan to wait for it
Schedulers.computation().scheduleDirect {
WorkManager.initialize(
this,
androidx.work.Configuration.Builder()
.setWorkerFactory(notificationWorkerFactory.get())
.build()
)
}
WorkManager.initialize(
this,
androidx.work.Configuration.Builder()
.setWorkerFactory(notificationWorkerFactory)
.build()
)
}
override fun attachBaseContext(base: Context) {