Skip to content

Commit b511e4a

Browse files
committed
refactor: RouteResultViewModel에 Origin, Destination Place 추가로 저장하기
1 parent 5c62b0a commit b511e4a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

presentation/src/main/java/com/stop/ui/route/RouteFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class RouteFragment : Fragment() {
115115
routeViewModel.lastTimeResponse.observe(viewLifecycleOwner) { event ->
116116
event.getContentIfNotHandled()?.let { response ->
117117
routeResultViewModel.setLastTimes(response)
118+
routeResultViewModel.setOrigin(routeViewModel.origin.value)
119+
routeResultViewModel.setDestination(routeViewModel.destination.value)
118120
binding.root.findNavController()
119121
.navigate(R.id.action_routeFragment_to_routeDetailFragment)
120122
}

presentation/src/main/java/com/stop/ui/route/RouteResultViewModel.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData
55
import androidx.lifecycle.ViewModel
66
import com.stop.domain.model.route.TransportLastTime
77
import com.stop.domain.model.route.tmap.custom.Itinerary
8+
import com.stop.model.route.Place
89

910
class RouteResultViewModel : ViewModel() {
1011

@@ -16,11 +17,27 @@ class RouteResultViewModel : ViewModel() {
1617
val lastTimes: LiveData<List<TransportLastTime?>>
1718
get() = _lastTimes
1819

20+
private val _origin = MutableLiveData<Place>()
21+
val origin: LiveData<Place>
22+
get() = _origin
23+
24+
private val _destination = MutableLiveData<Place>()
25+
val destination: LiveData<Place>
26+
get() = _destination
27+
1928
fun setItineraries(itinerary: Itinerary) {
2029
_itinerary.value = itinerary
2130
}
2231

2332
fun setLastTimes(lastTimes: List<TransportLastTime?>) {
2433
_lastTimes.value = lastTimes
2534
}
35+
36+
fun setOrigin(originPlace: Place?) {
37+
_origin.value = originPlace ?: return
38+
}
39+
40+
fun setDestination(destinationPlace: Place?) {
41+
_destination.value = destinationPlace ?: return
42+
}
2643
}

0 commit comments

Comments
 (0)