From 781586a009ac5fbd4eb22c6aa78bfcfe28a1d29b Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Tue, 1 Dec 2020 07:39:30 +0100 Subject: [PATCH] fix workmanager crashing because of async initialization (#2003) --- .../keylesspalace/tusky/TuskyApplication.kt | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt index 142d28b1..fe5f3b89 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt +++ b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.kt @@ -33,11 +33,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 @@ -48,7 +46,7 @@ class TuskyApplication : Application(), HasAndroidInjector { lateinit var androidInjector: DispatchingAndroidInjector @Inject - lateinit var notificationWorkerFactory: Lazy + lateinit var notificationWorkerFactory: NotificationWorkerFactory override fun onCreate() { // Uncomment me to get StrictMode violation logs @@ -89,15 +87,12 @@ class TuskyApplication : Application(), HasAndroidInjector { SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.ARGB_8888) BigImageViewer.initialize(GlideCustomImageLoader.with(this)) - // 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) {