Skip to content

Commit

Permalink
inject StockDispatcher to fix code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdyrod committed Dec 22, 2023
1 parent b4af35d commit d813c18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package org.dhis2.android.rtsm.coroutines

import kotlinx.coroutines.Dispatchers
import org.dhis2.commons.viewmodel.DispatcherProvider
import javax.inject.Inject

class StockDispatcherProvider : DispatcherProvider {
class StockDispatcherProvider @Inject constructor() : DispatcherProvider {

override fun io() = Dispatchers.IO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package org.dhis2.android.rtsm.services
import androidx.lifecycle.liveData
import io.reactivex.Single
import io.reactivex.disposables.CompositeDisposable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.apache.commons.lang3.math.NumberUtils
import org.dhis2.android.rtsm.coroutines.StockDispatcherProvider
import org.dhis2.android.rtsm.data.AppConfig
import org.dhis2.android.rtsm.data.models.IdentifiableModel
import org.dhis2.android.rtsm.data.models.SearchParametersModel
Expand Down Expand Up @@ -36,14 +36,15 @@ class StockManagerImpl @Inject constructor(
private val disposable: CompositeDisposable,
private val schedulerProvider: BaseSchedulerProvider,
private val ruleValidationHelper: RuleValidationHelper,
private val dispatcher: StockDispatcherProvider,
) : StockManager {

override suspend fun search(
query: SearchParametersModel,
ou: String?,
config: AppConfig,
): SearchResult {
val list = withContext(Dispatchers.IO) {
val list = withContext(dispatcher.io()) {
var teiRepository = d2.trackedEntityModule().trackedEntityInstanceQuery()

if (!ou.isNullOrEmpty()) {
Expand Down

0 comments on commit d813c18

Please sign in to comment.