Skip to content

Commit 5bf18bf

Browse files
committed
fix: UI가 없을 시 패널이 나타나지 않던 버그 수정
1 parent 6846b5a commit 5bf18bf

File tree

4 files changed

+66
-38
lines changed

4 files changed

+66
-38
lines changed

presentation/src/main/java/com/stop/ui/map/MapFragment.kt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class MapFragment : Fragment(), MapHandler {
5353

5454
override fun alertTMapReady() {
5555
requestPermissionsLauncher.launch(PERMISSIONS)
56-
tMap.initListener()
5756

57+
tMap.initListener()
5858
addBookmarkMarker()
5959
observeClickPlace()
6060
observeClickCurrentLocation()
@@ -80,6 +80,8 @@ class MapFragment : Fragment(), MapHandler {
8080

8181
binding.layoutCurrent.setOnClickListener {
8282
requestPermissionsLauncher.launch(PERMISSIONS)
83+
84+
tMap.isTracking = true
8385
tMap.tMapView.setCenterPoint(
8486
placeSearchViewModel.currentLocation.latitude,
8587
placeSearchViewModel.currentLocation.longitude,
@@ -93,7 +95,6 @@ class MapFragment : Fragment(), MapHandler {
9395
placeSearchViewModel.currentLocation.longitude
9496
)
9597
)
96-
tMap.isTracking = true
9798
}
9899

99100
binding.layoutBookmark.setOnClickListener {
@@ -181,6 +182,20 @@ class MapFragment : Fragment(), MapHandler {
181182
placeSearchViewModel.getGeoLocationInfo(tMapPoint.latitude, tMapPoint.longitude)
182183
}
183184

185+
override fun setOnLocationChangeListener(location: android.location.Location) {
186+
placeSearchViewModel.currentLocation = Location(location.latitude, location.longitude)
187+
}
188+
189+
override fun setOnDisableScrollWIthZoomLevelListener() {
190+
if (binding.layoutPanel.visibility == View.VISIBLE) {
191+
binding.layoutPanel.visibility = View.GONE
192+
tMap.tMapView.removeTMapMarkerItem(PLACE_MARKER)
193+
} else {
194+
setViewVisibility()
195+
mapUIVisibility = mapUIVisibility.xor(View.GONE)
196+
}
197+
}
198+
184199
private fun setViewVisibility() {
185200
with(binding) {
186201
layoutSearch.visibility = mapUIVisibility
@@ -198,20 +213,6 @@ class MapFragment : Fragment(), MapHandler {
198213
).toInt()
199214
}
200215

201-
override fun setOnLocationChangeListener(location: android.location.Location) {
202-
placeSearchViewModel.currentLocation = Location(location.latitude, location.longitude)
203-
}
204-
205-
override fun setOnDisableScrollWIthZoomLevelListener() {
206-
if (binding.layoutPanel.visibility == View.VISIBLE) {
207-
binding.layoutPanel.visibility = View.GONE
208-
tMap.tMapView.removeTMapMarkerItem(PLACE_MARKER)
209-
} else {
210-
setViewVisibility()
211-
mapUIVisibility = mapUIVisibility.xor(View.GONE)
212-
}
213-
}
214-
215216
override fun onDestroyView() {
216217
_binding = null
217218

@@ -238,4 +239,4 @@ class MapFragment : Fragment(), MapHandler {
238239
private val PERMISSIONS =
239240
arrayOf(permission.ACCESS_FINE_LOCATION, permission.ACCESS_COARSE_LOCATION)
240241
}
241-
}
242+
}
Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,73 @@
11
package com.stop.ui.map
22

33
import android.content.Context
4+
import android.graphics.PointF
5+
import com.skt.tmap.TMapPoint
6+
import com.skt.tmap.TMapView
7+
import com.skt.tmap.TMapView.OnClickListenerCallback
8+
import com.skt.tmap.overlay.TMapMarkerItem
9+
import com.skt.tmap.poi.TMapPOIItem
410
import com.stop.R
511
import com.stop.model.Location
612
import com.stop.ui.util.TMap
13+
import java.util.ArrayList
714

815
class MapTMap(
916
context: Context,
1017
private val handler: MapHandler,
1118
) : TMap(context, handler) {
1219

20+
private val enablePoints = mutableSetOf<Location>()
21+
private var isLongClick = false
22+
1323
fun initListener() {
14-
val enablePoint = mutableSetOf<Location>()
15-
tMapView.setOnEnableScrollWithZoomLevelListener { _, centerPoint ->
16-
enablePoint.add(Location(centerPoint.latitude, centerPoint.longitude))
17-
isTracking = false
24+
tMapView.setOnClickListenerCallback(onClickListenerCallback)
25+
tMapView.setOnLongClickListenerCallback(onLongClickListenerCallback)
26+
tMapView.setOnEnableScrollWithZoomLevelListener(onEnableScrollWithZoomLevelCallback)
27+
}
28+
29+
private val onClickListenerCallback = object : OnClickListenerCallback {
30+
override fun onPressDown(
31+
p0: ArrayList<TMapMarkerItem>?,
32+
p1: ArrayList<TMapPOIItem>?,
33+
p2: TMapPoint?,
34+
p3: PointF?
35+
) {
36+
isLongClick = false
1837
}
1938

20-
tMapView.setOnDisableScrollWithZoomLevelListener { _, _ ->
21-
if (enablePoint.size == SAME_POINT) {
39+
override fun onPressUp(
40+
p0: ArrayList<TMapMarkerItem>?,
41+
p1: ArrayList<TMapPOIItem>?,
42+
p2: TMapPoint?,
43+
p3: PointF?
44+
) {
45+
if (enablePoints.size < SCROLL_NUM && isLongClick.not()) {
2246
handler.setOnDisableScrollWIthZoomLevelListener()
2347
}
24-
enablePoint.clear()
25-
}
2648

27-
tMapView.setOnLongClickListenerCallback { _, _, tMapPoint ->
28-
addMarker(
29-
PLACE_MARKER,
30-
PLACE_MARKER_IMG,
31-
tMapPoint
32-
)
49+
enablePoints.clear()
50+
}
51+
}
3352

53+
private val onLongClickListenerCallback =
54+
TMapView.OnLongClickListenerCallBack { _, _, tMapPoint ->
55+
isLongClick = true
3456
tMapView.setCenterPoint(tMapPoint.latitude, tMapPoint.longitude, true)
57+
addMarker(PLACE_MARKER, PLACE_MARKER_IMG, tMapPoint)
3558
handler.setPanel(tMapPoint)
3659
}
37-
}
60+
61+
private val onEnableScrollWithZoomLevelCallback =
62+
TMapView.OnEnableScrollWithZoomLevelCallback { _, tMapPoint ->
63+
isTracking = false
64+
enablePoints.add(Location(tMapPoint.latitude, tMapPoint.longitude))
65+
}
3866

3967
companion object {
4068
private const val PLACE_MARKER = "place_marker"
4169
private const val PLACE_MARKER_IMG = R.drawable.ic_place_marker
4270

43-
private const val SAME_POINT = 1
71+
private const val SCROLL_NUM = 3
4472
}
4573
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ open class TMap(
106106
private const val KOREA_LONGITUDE_MIN = 124.661865
107107
private const val KOREA_LONGITUDE_MAX = 132.550049
108108

109-
private const val PERSON_MARKER = "marker_person_pin"
109+
private const val PERSON_MARKER = "person_marker"
110110
private const val PERSON_MARKER_IMG = R.drawable.ic_person_marker
111111
}
112112
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@
5757
<androidx.constraintlayout.widget.ConstraintLayout
5858
android:id="@+id/layout_panel"
5959
android:layout_width="0dp"
60-
android:layout_height="0dp"
61-
android:layout_marginEnd="15dp"
60+
android:layout_height="170dp"
61+
android:layout_marginEnd="90dp"
6262
android:layout_marginTop="30dp"
6363
android:elevation="15dp"
6464
android:visibility="@{placeSearchViewModel.panelVisibility}"
6565
app:layout_constraintStart_toStartOf="@id/guideline_start"
66-
app:layout_constraintEnd_toStartOf="@id/layout_compass"
67-
app:layout_constraintTop_toTopOf="@id/layout_compass"
66+
app:layout_constraintEnd_toEndOf="parent"
6867
app:layout_constraintBottom_toBottomOf="@id/guideline_bottom">
6968

7069
<include

0 commit comments

Comments
 (0)