Skip to content

Commit 7654f6a

Browse files
committed
Revert "저장용: merge XML을 코드로 생성해서 추가하면 화면이 이상하게 보인다."
This reverts commit 5b7076f.
1 parent 5b7076f commit 7654f6a

File tree

9 files changed

+36
-457
lines changed

9 files changed

+36
-457
lines changed

presentation/src/main/java/com/stop/model/route/RouteItem.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ data class RouteItem(
1111
val lastTime: String?,
1212
val beforeColor: Int,
1313
val currentColor: Int,
14-
val type: RouteItemType,
15-
val typeName: String = "",
14+
val type: RouteItemType
1615
)
1716

1817
fun RouteItem.toFirstRouteItem(): RouteItem {
@@ -21,10 +20,7 @@ fun RouteItem.toFirstRouteItem(): RouteItem {
2120
)
2221
}
2322

24-
fun RouteItem.toLastRouteItem(
25-
name: String,
26-
coordinate: com.stop.model.route.Coordinate
27-
): RouteItem {
23+
fun RouteItem.toLastRouteItem(name: String, coordinate: com.stop.model.route.Coordinate): RouteItem {
2824
return this.copy(
2925
name = name,
3026
coordinate = Coordinate(coordinate.latitude, coordinate.longitude),

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

Lines changed: 0 additions & 44 deletions
This file was deleted.

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

Lines changed: 3 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
package com.stop.ui.route
22

3-
import android.graphics.Color
43
import android.graphics.Rect
54
import android.view.View
6-
import androidx.core.content.ContextCompat
75
import androidx.recyclerview.widget.RecyclerView
8-
import com.stop.R
96
import com.stop.databinding.RouteItemBinding
10-
import com.stop.domain.model.route.tmap.custom.*
11-
import com.stop.model.route.RouteItem
12-
import com.stop.model.route.RouteItemType
7+
import com.stop.domain.model.route.tmap.custom.Itinerary
138

149
class RouteViewHolder(
1510
private val binding: RouteItemBinding
1611
) : RecyclerView.ViewHolder(binding.root) {
1712

18-
private val adapter = RouteDetailAdapter()
19-
var routeItemColor = 0
13+
private val adapter = TimeLineAdapter()
2014

2115
init {
2216
binding.recyclerviewTimeLine.adapter = adapter
@@ -37,67 +31,8 @@ class RouteViewHolder(
3731

3832
fun bind(itinerary: Itinerary) {
3933
binding.textViewExpectedRequiredTime.text = secondToHourAndMinute(itinerary.totalTime)
40-
val routeItems = mutableListOf<RouteItem>()
4134

42-
itinerary.routes.forEach { route ->
43-
routeItems.add(
44-
RouteItem(
45-
name = route.start.name,
46-
coordinate = route.start.coordinate,
47-
mode = getRouteItemMode(route),
48-
distance = route.distance,
49-
travelTime = route.sectionTime.toInt(),
50-
lastTime = "",
51-
beforeColor = getRouteItemColor(route, false),
52-
currentColor = getRouteItemColor(route, true),
53-
type = RouteItemType.PATH,
54-
typeName = getTypeName(route),
55-
)
56-
)
57-
}
58-
adapter.submitList(routeItems)
59-
binding.timeLineContainer.submitList(itinerary.routes)
60-
}
61-
62-
private fun getTypeName(route: Route): String {
63-
return when(route) {
64-
is WalkRoute -> "도보"
65-
is TransportRoute -> getSubwayTypeName(route)
66-
else -> ""
67-
}
68-
}
69-
70-
private fun getSubwayTypeName(route: TransportRoute): String {
71-
return when(route.mode) {
72-
MoveType.SUBWAY -> route.routeInfo.replace("수도권", "")
73-
MoveType.BUS -> route.routeInfo.split(":")[1]
74-
else -> route.routeInfo
75-
}
76-
}
77-
78-
private fun getRouteItemColor(route: Route, isCurrent: Boolean): Int {
79-
return if (isCurrent) {
80-
when (route) {
81-
is TransportRoute -> Color.parseColor("#${route.routeColor}")
82-
is WalkRoute -> ContextCompat.getColor(binding.root.context, R.color.main_yellow)
83-
else -> ContextCompat.getColor(binding.root.context, R.color.main_lighter_grey)
84-
}
85-
} else {
86-
if (routeItemColor != 0) {
87-
routeItemColor
88-
} else {
89-
getRouteItemColor(route, true)
90-
}
91-
}
92-
}
93-
94-
private fun getRouteItemMode(route: Route): Int {
95-
return when (route.mode) {
96-
MoveType.WALK, MoveType.TRANSFER -> R.drawable.ic_walk_white
97-
MoveType.BUS -> R.drawable.ic_bus_white
98-
MoveType.SUBWAY -> R.drawable.ic_subway_white
99-
else -> R.drawable.ic_star_white
100-
}
35+
adapter.submitList(itinerary.routes)
10136
}
10237

10338
private fun secondToHourAndMinute(second: Int): String {

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

Lines changed: 0 additions & 121 deletions
This file was deleted.

presentation/src/main/java/com/stop/ui/util/DrawerStringUtils.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.stop.ui.util
22

3+
import com.stop.domain.model.route.seoul.subway.StationLastTime
34
import com.stop.domain.model.route.tmap.custom.Itinerary
45
import com.stop.model.route.RouteItem
56
import java.text.DecimalFormat

presentation/src/main/res/layout/route_item.xml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,18 @@
2727
app:layout_constraintTop_toTopOf="@id/guideline_start_horizontal"
2828
tools:text="1시간 10분" />
2929

30-
<com.stop.ui.route.TimeLineContainer
31-
android:id="@+id/time_line_container"
32-
android:layout_width="0dp"
33-
android:layout_height="wrap_content"
34-
app:layout_constraintEnd_toEndOf="@id/guideline_end_vertical"
35-
app:layout_constraintStart_toStartOf="@id/guideline_start_vertical"
36-
app:layout_constraintTop_toBottomOf="@id/text_view_required_time_text" />
37-
3830
<androidx.recyclerview.widget.RecyclerView
3931
android:id="@+id/recyclerview_time_line"
4032
android:layout_width="0dp"
4133
android:layout_height="wrap_content"
34+
android:orientation="horizontal"
35+
tools:listitem="@layout/time_line_item"
4236
android:layout_marginBottom="16dp"
43-
android:orientation="vertical"
44-
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
4537
app:layout_constraintBottom_toBottomOf="parent"
38+
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
39+
app:layout_constraintTop_toBottomOf="@id/text_view_required_time_text"
4640
app:layout_constraintEnd_toStartOf="@id/guideline_end_vertical"
47-
app:layout_constraintStart_toStartOf="@id/guideline_start_vertical"
48-
app:layout_constraintTop_toBottomOf="@id/time_line_container"
49-
tools:listitem="@layout/route_path_at_time_line_item" />
41+
app:layout_constraintStart_toStartOf="@id/guideline_start_vertical" />
5042

5143
<androidx.constraintlayout.widget.Guideline
5244
android:id="@+id/guideline_start_vertical"

0 commit comments

Comments
 (0)