Skip to content

Commit 8d3a53e

Browse files
committed
feat : mission일 때 TrackingMode 수정 & 현재 위치 마커찍기
- tmap-sdk 버전 업그레이드함 (마커 애니메이션 효과 없앰)
1 parent 5961598 commit 8d3a53e

File tree

9 files changed

+24
-91
lines changed

9 files changed

+24
-91
lines changed

presentation/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ dependencies {
6262

6363
// TMap SDK
6464
implementation files('libs/vsm-tmap-sdk-v2-android-1.6.60.aar')
65-
implementation files('libs/tmap-sdk-1.1.aar')
65+
implementation files('libs/tmap-sdk-1.2.aar')
6666

6767
// Hilt
6868
implementation 'com.google.dagger:hilt-android:2.44'

presentation/src/main/java/com/stop/ui/mission/MissionFragment.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class MissionFragment : Fragment(), MissionHandler {
3434

3535
private lateinit var tMap: MissionTMap
3636

37-
private var points = arrayListOf<TMapPoint>()
38-
3937
private var state = State.FOREGROUND
4038

4139
override fun onCreateView(
@@ -161,7 +159,6 @@ class MissionFragment : Fragment(), MissionHandler {
161159

162160
override fun alertTMapReady() {
163161
requestPermissionsLauncher.launch(PERMISSIONS)
164-
tMap.setTrackingMode()
165162
}
166163

167164
override fun setOnEnableScrollWithZoomLevelListener() {
@@ -176,33 +173,36 @@ class MissionFragment : Fragment(), MissionHandler {
176173
ActivityResultContracts.RequestMultiplePermissions()
177174
) { permissions ->
178175
if (permissions.entries.any { it.value }) {
179-
tMap.setTrackingMode()
176+
tMap.isTracking = false
180177
}
181178
}
182179

183180
private fun drawPersonLine() {
184181
var first = 0
182+
lateinit var beforeLocation: Location
185183
lifecycleScope.launch {
186184
viewModel.userLocation.collect { userLocation ->
187-
if (first == 0) {
188-
first += 1
189-
} else if (first == 1) {
190-
points.add(userLocation)
185+
if (first < 2) {
186+
beforeLocation = userLocation
191187
first += 1
192188
} else {
193-
tMap.tMapView.removeTMapPolyLine(Marker.PERSON_LINE + PERSON_LINE_NUM.toString())
194-
Log.d("MissionWorker", "drawLine $points")
195-
points.add(userLocation)
189+
val nowLocation = TMapPoint(userLocation.latitude, userLocation.longitude)
196190
tMap.drawMoveLine(
197-
points,
191+
nowLocation,
192+
TMapPoint(beforeLocation.latitude, beforeLocation.longitude),
198193
Marker.PERSON_LINE + PERSON_LINE_NUM.toString(),
199194
Marker.PERSON_LINE_COLOR
200195
)
201-
196+
tMap.addMarker(Marker.PERSON_MARKER, Marker.PERSON_MARKER_IMG, nowLocation)
197+
viewModel.personCurrentLocation = userLocation
198+
if (tMap.isTracking) {
199+
tMap.tMapView.setCenterPoint(userLocation.latitude, userLocation.longitude)
200+
}
201+
beforeLocation = userLocation
202+
PERSON_LINE_NUM += 1
202203
}
203204

204205
}
205-
206206
}
207207
}
208208

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
package com.stop.ui.mission
22

3-
import com.skt.tmap.TMapPoint
3+
import com.stop.model.Location
44
import kotlinx.coroutines.flow.MutableStateFlow
5-
import kotlinx.coroutines.flow.StateFlow
6-
import kotlinx.coroutines.flow.asStateFlow
75

86
class MissionManager {
97

10-
var initLocation = MutableStateFlow(TMapPoint())
11-
var userLocation = MutableStateFlow(TMapPoint())
8+
var userLocation = MutableStateFlow(Location(0.0, 0.0))
129

13-
private var _userState = MutableStateFlow<UserState>(UserState.Foreground())
14-
val userState: StateFlow<UserState>
15-
get() = _userState.asStateFlow()
16-
17-
fun setLocation(location: TMapPoint) {
18-
_userState.value = UserState.Foreground(location)
19-
}
20-
21-
}
22-
23-
sealed interface UserState {
24-
25-
data class Foreground(val location: TMapPoint = TMapPoint()) : UserState
26-
27-
data class Background(val locations: List<TMapPoint> = emptyList()) : UserState
2810
}
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
package com.stop.ui.mission
22

33
import android.content.Context
4-
import android.util.Log
54
import com.skt.tmap.TMapPoint
65
import com.skt.tmap.overlay.TMapPolyLine
7-
import com.stop.ui.util.Marker
86
import com.stop.ui.util.TMap
97

108
class MissionTMap(
119
context: Context,
1210
handler: MissionHandler,
1311
) : TMap(context, handler) {
1412

15-
fun drawMoveLine(points: ArrayList<TMapPoint>, id: String, color: Int) {
13+
fun drawMoveLine(nowLocation: TMapPoint, beforeLocation: TMapPoint, id: String, color: Int) {
14+
val points = arrayListOf(nowLocation, beforeLocation)
1615
val polyLine = TMapPolyLine(id, points).apply {
1716
lineColor = color
1817
outLineColor = color
1918
}
2019
tMapView.addTMapPolyLine(polyLine)
2120
}
2221

23-
companion object {
24-
private var PERSON_LINE_NUM = 0
25-
}
26-
2722
}

presentation/src/main/java/com/stop/ui/mission/MissionViewModel.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ package com.stop.ui.mission
33
import androidx.lifecycle.*
44
import androidx.work.OneTimeWorkRequestBuilder
55
import androidx.work.WorkManager
6-
import com.stop.domain.model.route.TransportLastTime
7-
import com.stop.domain.usecase.nowlocation.*
86
import com.stop.model.ErrorType
97
import com.stop.model.Event
108
import com.stop.model.Location
11-
import com.stop.model.State
129
import dagger.hilt.android.lifecycle.HiltViewModel
1310
import kotlinx.coroutines.delay
1411
import kotlinx.coroutines.launch
@@ -107,13 +104,6 @@ class MissionViewModel @Inject constructor(
107104
workManager.enqueue(workRequest)
108105
}
109106

110-
fun setOnState(state: State) {
111-
if (state == State.FOREGROUND) {
112-
113-
}
114-
}
115-
116-
117107
companion object {
118108
private const val DELAY_TIME = 1000L
119109
private const val TIME_ZERO = 0

presentation/src/main/java/com/stop/ui/mission/MissionWorker.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import androidx.work.ForegroundInfo
1717
import androidx.work.WorkManager
1818
import androidx.work.WorkerParameters
1919
import com.google.android.gms.location.*
20-
import com.skt.tmap.TMapPoint
2120
import com.stop.R
2221
import com.stop.isMoreThanOreo
22+
import com.stop.model.Location
2323
import dagger.assisted.Assisted
2424
import dagger.assisted.AssistedInject
2525
import kotlinx.coroutines.delay
@@ -74,7 +74,7 @@ class MissionWorker @AssistedInject constructor(
7474
override fun onLocationResult(locationResult: LocationResult) {
7575
for (location in locationResult.locations) {
7676
if (location != null) {
77-
missionManager.userLocation.value = TMapPoint(location.latitude, location.longitude)
77+
missionManager.userLocation.value = Location(location.latitude, location.longitude)
7878
}
7979
}
8080
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,4 @@ object Marker {
1111
const val PERSON_MARKER_IMG = R.drawable.ic_person_marker
1212
const val PERSON_LINE = "person_line"
1313
const val PERSON_LINE_COLOR = Color.MAGENTA
14-
15-
const val BOOKMARK_MARKER_IMG = R.drawable.ic_bookmark_marker
16-
17-
const val BUS_MARKER = "bus_marker"
18-
const val BUS_MARKER_IMG = R.drawable.ic_bus_marker
19-
const val BUS_LINE = "bus_line"
20-
const val BUS_LINE_COLOR = Color.BLUE
21-
22-
const val SUBWAY_MARKER = "subway_marker"
23-
const val SUBWAY_MARKER_IMG = R.drawable.ic_subway_marker
24-
const val SUBWAY_LINE = "subway_line"
25-
const val SUBWAY_LINE_COLOR = Color.BLUE
26-
2714
}

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

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ open class TMap(
2020
lateinit var initLocation: Location
2121

2222
var isTracking = true
23-
// var isTransportTracking = false
2423

2524
fun init() {
2625
tMapView = TMapView(context).apply {
@@ -54,38 +53,17 @@ open class TMap(
5453
manager.setOnLocationChangeListener(onLocationChangeListener)
5554
}
5655

57-
// fun trackingTransport(location: Location) {
58-
// if (isTransportTracking.not()) {
59-
// return
60-
// }
61-
// tMapView.setCenterPoint(
62-
// location.latitude,
63-
// location.longitude,
64-
// true
65-
// )
66-
// }
67-
6856
private val onLocationChangeListener = TMapGpsManager.OnLocationChangedListener { location ->
6957
if (location != null && checkLocationInTMapLocation(location)) {
70-
val beforeLocation = tMapView.locationPoint
7158
val nowLocation = TMapPoint(location.latitude, location.longitude)
72-
if (handler is MissionHandler) {
73-
if (Location(beforeLocation.latitude, beforeLocation.longitude) != initLocation) {
74-
handler.setOnLocationChangeListener(nowLocation, beforeLocation, true)
75-
} else {
76-
handler.setOnLocationChangeListener(nowLocation, beforeLocation, false)
77-
}
78-
} else if (handler is MapHandler) {
79-
handler.setOnLocationChangeListener(location)
80-
}
81-
82-
tMapView.setLocationPoint(location.latitude, location.longitude)
8359

60+
(handler as MapHandler).setOnLocationChangeListener(location)
8461
addMarker(
8562
Marker.PERSON_MARKER,
8663
Marker.PERSON_MARKER_IMG,
8764
nowLocation
8865
)
66+
tMapView.setLocationPoint(location.latitude, location.longitude)
8967

9068
if (isTracking) {
9169
tMapView.setCenterPoint(location.latitude, location.longitude, true)
@@ -106,6 +84,7 @@ open class TMap(
10684
icon
10785
)?.toBitmap()
10886
tMapPoint = location
87+
isAnimation = false
10988
}
11089

11190
tMapView.removeTMapMarkerItem(id)

0 commit comments

Comments
 (0)