Skip to content

Commit

Permalink
refactor: [ANDROAPP-6029] remove EventDetailIdlingResourceSingleton (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmateos authored and Balcan committed May 24, 2024
1 parent 2305a33 commit 0db2953
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 33 deletions.
3 changes: 0 additions & 3 deletions app/src/androidTest/java/org/dhis2/usescases/BaseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.dhis2.commons.idlingresource.SearchIdlingResourceSingleton
import org.dhis2.commons.prefs.Preference
import org.dhis2.form.ui.idling.FormCountingIdlingResource
import org.dhis2.usescases.eventsWithoutRegistration.EventIdlingResourceSingleton
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.ui.EventDetailIdlingResourceSingleton
import org.dhis2.usescases.programEventDetail.eventList.EventListIdlingResourceSingleton
import org.dhis2.usescases.teiDashboard.dashboardfragments.teidata.TeiDataIdlingResourceSingleton
import org.junit.After
Expand Down Expand Up @@ -87,7 +86,6 @@ open class BaseTest {
SearchIdlingResourceSingleton.countingIdlingResource,
TeiDataIdlingResourceSingleton.countingIdlingResource,
EventIdlingResourceSingleton.countingIdlingResource,
EventDetailIdlingResourceSingleton.countingIdlingResource,
)
}

Expand All @@ -100,7 +98,6 @@ open class BaseTest {
SearchIdlingResourceSingleton.countingIdlingResource,
TeiDataIdlingResourceSingleton.countingIdlingResource,
EventIdlingResourceSingleton.countingIdlingResource,
EventDetailIdlingResourceSingleton.countingIdlingResource,
)
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.coroutines.launch
import org.dhis2.commons.extensions.truncate
import org.dhis2.commons.locationprovider.LocationProvider
import org.dhis2.form.data.GeometryController
import org.dhis2.usescases.eventsWithoutRegistration.EventIdlingResourceSingleton
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.domain.ConfigureEventCatCombo
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.domain.ConfigureEventCoordinates
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.domain.ConfigureEventDetails
Expand Down Expand Up @@ -141,7 +142,7 @@ class EventDetailsViewModel(
}

private fun setUpEventDetails() {
EventDetailIdlingResourceSingleton.increment()
EventIdlingResourceSingleton.increment()
viewModelScope.launch {
configureEventDetails(
selectedDate = eventDate.value.currentDate,
Expand All @@ -154,21 +155,21 @@ class EventDetailsViewModel(
.flowOn(Dispatchers.IO)
.collect {
_eventDetails.value = it
EventDetailIdlingResourceSingleton.decrement()
EventIdlingResourceSingleton.decrement()
}
}
}

fun setUpEventReportDate(selectedDate: Date? = null) {
EventDetailIdlingResourceSingleton.increment()
EventIdlingResourceSingleton.increment()
viewModelScope.launch {
configureEventReportDate(selectedDate)
.flowOn(Dispatchers.IO)
.collect {
_eventDate.value = it
setUpEventDetails()
setUpOrgUnit(selectedDate = it.currentDate)
EventDetailIdlingResourceSingleton.decrement()
EventIdlingResourceSingleton.decrement()
}
}
}
Expand All @@ -195,14 +196,14 @@ class EventDetailsViewModel(
}

fun setUpCategoryCombo(categoryOption: Pair<String, String?>? = null) {
EventDetailIdlingResourceSingleton.increment()
EventIdlingResourceSingleton.increment()
viewModelScope.launch {
configureEventCatCombo(categoryOption)
.flowOn(Dispatchers.IO)
.collect {
_eventCatCombo.value = it
setUpEventDetails()
EventDetailIdlingResourceSingleton.decrement()
EventIdlingResourceSingleton.decrement()
}
}
}
Expand All @@ -213,7 +214,7 @@ class EventDetailsViewModel(
}

private fun setUpCoordinates(value: String? = "") {
EventDetailIdlingResourceSingleton.increment()
EventIdlingResourceSingleton.increment()
viewModelScope.launch {
configureEventCoordinates(value)
.flowOn(Dispatchers.IO)
Expand All @@ -233,20 +234,20 @@ class EventDetailsViewModel(
)
_eventCoordinates.value = eventCoordinates
setUpEventDetails()
EventDetailIdlingResourceSingleton.decrement()
EventIdlingResourceSingleton.decrement()
}
}
}

fun setUpEventTemp(status: EventTempStatus? = null, isChecked: Boolean = true) {
EventDetailIdlingResourceSingleton.increment()
EventIdlingResourceSingleton.increment()
if (isChecked) {
configureEventTemp(status).apply {
_eventTemp.value = this
setUpEventDetails()
}
}
EventDetailIdlingResourceSingleton.decrement()
EventIdlingResourceSingleton.decrement()
}

fun getSelectableDates(eventDate: EventDate): SelectableDates {
Expand Down

0 comments on commit 0db2953

Please sign in to comment.