Address repeated initializatin of WorkManagerImpl in #5887
This commit is contained in:
parent
4ced6ca179
commit
8950aa38ea
|
@ -22,6 +22,8 @@ import android.os.Looper
|
||||||
import androidx.lifecycle.ProcessLifecycleOwner
|
import androidx.lifecycle.ProcessLifecycleOwner
|
||||||
import androidx.work.Configuration
|
import androidx.work.Configuration
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
|
import androidx.work.impl.WorkManagerImpl
|
||||||
|
import androidx.work.impl.utils.taskexecutor.WorkManagerTaskExecutor
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import org.matrix.android.sdk.BuildConfig
|
import org.matrix.android.sdk.BuildConfig
|
||||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||||
|
@ -66,7 +68,12 @@ internal class TestMatrix(context: Context, matrixConfiguration: MatrixConfigura
|
||||||
.setExecutor(Executors.newCachedThreadPool())
|
.setExecutor(Executors.newCachedThreadPool())
|
||||||
.setWorkerFactory(matrixWorkerFactory)
|
.setWorkerFactory(matrixWorkerFactory)
|
||||||
.build()
|
.build()
|
||||||
WorkManager.initialize(appContext, configuration)
|
val delegate = WorkManagerImpl(
|
||||||
|
context,
|
||||||
|
configuration,
|
||||||
|
WorkManagerTaskExecutor(configuration.taskExecutor)
|
||||||
|
)
|
||||||
|
WorkManagerImpl.setDelegate(delegate)
|
||||||
uiHandler.post {
|
uiHandler.post {
|
||||||
ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver)
|
ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue