Skip to content

Commit

Permalink
[ANDROAPP-6315] Inject FilterManager into SearchTEIViewModel
Browse files Browse the repository at this point in the history
Signed-off-by: andresmr <[email protected]>
  • Loading branch information
andresmr committed Jul 11, 2024
1 parent 1b6128a commit 400b850
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class SearchTEIViewModel(
private val mapStyleConfig: MapStyleConfiguration,
private val resourceManager: ResourceManager,
private val displayNameProvider: DisplayNameProvider,
private val filterManager: FilterManager,
) : ViewModel() {

private val _pageConfiguration = MutableLiveData<NavigationPageConfigurator>()
Expand All @@ -66,8 +67,6 @@ class SearchTEIViewModel(
private val _legacyInteraction = MutableLiveData<LegacyInteraction?>()
val legacyInteraction: LiveData<LegacyInteraction?> = _legacyInteraction

val filterManager: FilterManager = FilterManager.getInstance()

private val _refreshData = MutableLiveData(Unit)
val refreshData: LiveData<Unit> = _refreshData

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.dhis2.commons.date.DateUtils;
import org.dhis2.commons.di.dagger.PerActivity;
import org.dhis2.commons.filters.DisableHomeFiltersFromSettingsApp;
import org.dhis2.commons.filters.FilterManager;
import org.dhis2.commons.filters.FiltersAdapter;
import org.dhis2.commons.filters.data.FilterPresenter;
import org.dhis2.commons.filters.data.FilterRepository;
Expand Down Expand Up @@ -289,7 +290,8 @@ SearchTeiViewModelFactory providesViewModelFactory(
NetworkUtils networkUtils,
D2 d2,
ResourceManager resourceManager,
DisplayNameProvider displayNameProvider
DisplayNameProvider displayNameProvider,
FilterManager filterManager
) {
return new SearchTeiViewModelFactory(
searchRepository,
Expand All @@ -302,7 +304,8 @@ SearchTeiViewModelFactory providesViewModelFactory(
new SearchDispatchers(),
new MapStyleConfiguration(d2),
resourceManager,
displayNameProvider
displayNameProvider,
filterManager
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.dhis2.usescases.searchTrackEntity

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import org.dhis2.commons.filters.FilterManager
import org.dhis2.commons.network.NetworkUtils
import org.dhis2.commons.resources.ResourceManager
import org.dhis2.commons.viewmodel.DispatcherProvider
Expand All @@ -21,6 +22,7 @@ class SearchTeiViewModelFactory(
private val mapStyleConfig: MapStyleConfiguration,
private val resourceManager: ResourceManager,
private val displayNameProvider: DisplayNameProvider,
private val filterManager: FilterManager,
) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return SearchTEIViewModel(
Expand All @@ -35,6 +37,7 @@ class SearchTeiViewModelFactory(
mapStyleConfig,
resourceManager,
displayNameProvider,
filterManager,
) as T
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.test.setMain
import org.dhis2.commons.filters.FilterManager
import org.dhis2.commons.network.NetworkUtils
import org.dhis2.commons.resources.ResourceManager
import org.dhis2.commons.viewmodel.DispatcherProvider
Expand Down Expand Up @@ -51,6 +52,7 @@ class SearchTEIViewModelTest {
private val mapStyleConfiguration: MapStyleConfiguration = mock()
private val resourceManager: ResourceManager = mock()
private val displayNameProvider: DisplayNameProvider = mock()
private val filterManager: FilterManager = mock()

@ExperimentalCoroutinesApi
private val testingDispatcher = StandardTestDispatcher()
Expand Down Expand Up @@ -88,6 +90,7 @@ class SearchTEIViewModelTest {
mapStyleConfiguration,
resourceManager = resourceManager,
displayNameProvider = displayNameProvider,
filterManager = filterManager,
)
testingDispatcher.scheduler.advanceUntilIdle()
}
Expand Down

0 comments on commit 400b850

Please sign in to comment.