File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
presentation/src/main/java/com/stop/ui/route Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,9 @@ class RouteFragment : Fragment() {
82
82
}
83
83
84
84
viewModel.lastTimeResponse.observe(viewLifecycleOwner) {
85
- binding.root.findNavController().navigate(R .id.action_routeFragment_to_routeDetailFragment)
85
+ it.getContentIfNotHandled()?.let {
86
+ binding.root.findNavController().navigate(R .id.action_routeFragment_to_routeDetailFragment)
87
+ }
86
88
}
87
89
}
88
90
Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ class RouteViewModel @Inject constructor(
35
35
val routeResponse: LiveData <List <Itinerary >>
36
36
get() = _routeResponse
37
37
38
- private val _lastTimeResponse = MutableLiveData <List <String ?>>()
39
- val lastTimeResponse: LiveData <List <String ?>>
38
+ private val _lastTimeResponse = MutableLiveData <Event < List <String ?> >>()
39
+ val lastTimeResponse: LiveData <Event < List <String ?> >>
40
40
get() = _lastTimeResponse
41
41
42
42
private val _errorMessage = MutableLiveData <Event <ErrorType >>()
@@ -69,7 +69,7 @@ class RouteViewModel @Inject constructor(
69
69
fun calculateLastTransportTime (itinerary : Itinerary ) {
70
70
checkClickedItinerary(itinerary)
71
71
viewModelScope.launch {
72
- this @RouteViewModel._lastTimeResponse .value = getLastTransportTimeUseCase(itinerary)
72
+ this @RouteViewModel._lastTimeResponse .value = Event ( getLastTransportTimeUseCase(itinerary) )
73
73
}
74
74
}
75
75
@@ -90,7 +90,7 @@ class RouteViewModel @Inject constructor(
90
90
val lastTimes = _lastTimeResponse .value ? : return " 이 함수를 호출한 시점에 막차 데이터가 null인 논리적 오류가 발생했습니다."
91
91
92
92
return clickedItinerary.routes.mapIndexed { index, route ->
93
- " ${route.start.name} (${lastTimes[index]} )"
93
+ " ${route.start.name} (${lastTimes.peekContent() [index]} )"
94
94
}.joinToString(" -> " )
95
95
}
96
96
}
You can’t perform that action at this time.
0 commit comments