Skip to content

Commit ad82dec

Browse files
committed
feat : PR 싱크 후 추가 로직 추가
1 parent 0b33797 commit ad82dec

File tree

12 files changed

+80
-52
lines changed

12 files changed

+80
-52
lines changed

data/src/main/java/com/stop/data/remote/network/NearPlaceApiService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ interface NearPlaceApiService {
1111
suspend fun getNearPlaces(
1212
@Query("version") version: Int,
1313
@Query("searchKeyword") searchKeyword: String,
14-
@Query("centerLon") centerLon: Float,
15-
@Query("centerLat") centerLat: Float,
14+
@Query("centerLon") centerLon: Double,
15+
@Query("centerLat") centerLat: Double,
1616
@Query("appKey") appKey: String,
1717
): NetworkResult<NearPlcaeResponse>
1818

data/src/main/java/com/stop/data/remote/source/nearplace/NearPlaceRemoteDataSource.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ interface NearPlaceRemoteDataSource {
77
suspend fun getNearPlaces(
88
version : Int,
99
searchKeyword: String,
10-
centerLon: Float,
11-
centerLat: Float,
10+
centerLon: Double,
11+
centerLat: Double,
1212
appKey: String
1313
): List<Place>
1414

data/src/main/java/com/stop/data/remote/source/nearplace/NearPlaceRemoteDataSourceImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ internal class NearPlaceRemoteDataSourceImpl @Inject constructor(
1212
override suspend fun getNearPlaces(
1313
version: Int,
1414
searchKeyword: String,
15-
centerLon: Float,
16-
centerLat: Float,
15+
centerLon: Double,
16+
centerLat: Double,
1717
appKey: String
1818
): List<Place> {
1919
val result = nearPlaceApiService.getNearPlaces(

data/src/main/java/com/stop/data/repository/NearPlaceRepositoryImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ internal class NearPlaceRepositoryImpl @Inject constructor(
1414
override suspend fun getNearPlaces(
1515
version: Int,
1616
searchKeyword: String,
17-
centerLon: Float,
18-
centerLat: Float,
17+
centerLon: Double,
18+
centerLat: Double,
1919
appKey: String
2020
): Flow<List<Place>> = flow<List<Place>> {
2121
emit(

domain/src/main/java/com/stop/domain/repository/NearPlaceRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ interface NearPlaceRepository {
88
suspend fun getNearPlaces(
99
version: Int,
1010
searchKeyword: String,
11-
centerLon: Float,
12-
centerLat: Float,
11+
centerLon: Double,
12+
centerLat: Double,
1313
appKey: String
1414
): Flow<List<Place>>
1515

domain/src/main/java/com/stop/domain/usecase/nearplace/GetNearPlacesUseCase.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ interface GetNearPlacesUseCase {
88
suspend fun getNearPlaces(
99
version: Int,
1010
searchKeyword: String,
11-
centerLon: Float,
12-
centerLat: Float,
11+
centerLon: Double,
12+
centerLat: Double,
1313
appKey: String
1414
) : Flow<List<Place>>
1515

domain/src/main/java/com/stop/domain/usecase/nearplace/GetNearPlacesUseCaseImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ internal class GetNearPlacesUseCaseImpl @Inject constructor(
1212
override suspend fun getNearPlaces(
1313
version: Int,
1414
searchKeyword: String,
15-
centerLon: Float,
16-
centerLat: Float,
15+
centerLon: Double,
16+
centerLat: Double,
1717
appKey: String
1818
): Flow<List<Place>> =
1919
nearPlaceRepository.getNearPlaces(

presentation/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
id 'androidx.navigation.safeargs'
55
id 'kotlin-kapt'
66
id 'com.google.dagger.hilt.android'
7+
id 'kotlin-parcelize'
78
}
89

910
Properties properties = new Properties()

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

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.stop.ui.map
22

33
import android.Manifest.permission
44
import android.os.Bundle
5+
import android.util.Log
56
import android.view.LayoutInflater
67
import android.view.View
78
import android.view.ViewGroup
@@ -17,6 +18,7 @@ import com.skt.tmap.TMapPoint
1718
import com.skt.tmap.TMapView
1819
import com.skt.tmap.address.TMapAddressInfo
1920
import com.skt.tmap.overlay.TMapMarkerItem
21+
import com.stop.BuildConfig
2022
import com.stop.R
2123
import com.stop.databinding.FragmentMapBinding
2224
import com.stop.model.Location
@@ -34,7 +36,6 @@ class MapFragment : Fragment() {
3436

3537
private lateinit var tMapView: TMapView
3638
private var isTracking = true
37-
private var lastMarker = NONE_LOCATION
3839
private var mapUIVisibility = false
3940

4041
override fun onCreateView(
@@ -103,13 +104,12 @@ class MapFragment : Fragment() {
103104

104105
private fun clickLocation() {
105106
tMapView.setOnLongClickListenerCallback { _, _, tMapPoint ->
106-
lastMarker = TMapPoint(tMapPoint.latitude, tMapPoint.longitude)
107107
makeMarker(
108108
R.drawable.ic_baseline_location_on_32,
109-
lastMarker
109+
tMapPoint
110110
)
111-
tMapView.setCenterPoint(tMapPoint.latitude, tMapPoint.longitude, true)
112111

112+
tMapView.setCenterPoint(tMapPoint.latitude, tMapPoint.longitude, true)
113113
setPanel(tMapPoint)
114114
}
115115
}
@@ -149,15 +149,22 @@ class MapFragment : Fragment() {
149149
}
150150

151151
private fun makeMarker(icon: Int, location: TMapPoint) {
152-
val marker = TMapMarkerItem()
153-
marker.id = MARKER
154-
marker.icon = ContextCompat.getDrawable(
155-
requireActivity(),
156-
icon
157-
)?.toBitmap()
158-
marker.setTMapPoint(location.latitude, location.longitude)
159-
tMapView.removeTMapMarkerItem(MARKER)
160-
tMapView.addTMapMarkerItem(marker)
152+
val marker = TMapMarkerItem().apply {
153+
this.id = MARKER
154+
this.icon = ContextCompat.getDrawable(
155+
requireContext(),
156+
icon
157+
)?.toBitmap()
158+
this.tMapPoint = location
159+
}
160+
161+
try {
162+
tMapView.removeTMapMarkerItem(MARKER)
163+
tMapView.addTMapMarkerItem(marker)
164+
}catch (e : Exception){
165+
Log.e("ABC", e.printStackTrace().toString())
166+
}
167+
161168
}
162169

163170
private fun initBinding() {
@@ -182,11 +189,13 @@ class MapFragment : Fragment() {
182189

183190
private fun initTMap() {
184191
tMapView = TMapView(requireContext())
185-
tMapView.setSKTMapApiKey(T_MAP_API_KEY)
192+
tMapView.setSKTMapApiKey(BuildConfig.TMAP_APP_KEY)
186193
tMapView.setOnMapReadyListener {
187194
tMapView.mapType = TMapView.MapType.NIGHT
188195
tMapView.zoomLevel = 16
189196
requestPermissionsLauncher.launch(PERMISSIONS)
197+
198+
observeClickPlace()
190199
}
191200
tMapView.setOnEnableScrollWithZoomLevelListener { _, _ ->
192201
isTracking = false
@@ -233,19 +242,34 @@ class MapFragment : Fragment() {
233242
}
234243
}
235244
}
236-
245+
246+
private fun observeClickPlace() {
247+
placeSearchViewModel.clickPlace.observe(viewLifecycleOwner) { event ->
248+
event.getContentIfNotHandled()?.let { clickPlace ->
249+
val clickTmapPoint = TMapPoint(clickPlace.centerLat, clickPlace.centerLon)
250+
251+
tMapView.setCenterPoint(clickTmapPoint.latitude, clickTmapPoint.longitude, true)
252+
253+
setPanel(clickTmapPoint)
254+
255+
makeMarker(
256+
R.drawable.ic_baseline_location_on_32,
257+
clickTmapPoint
258+
)
259+
}
260+
}
261+
}
262+
237263
override fun onDestroyView() {
238264
_binding = null
239265
super.onDestroyView()
240266
}
241267

242268
companion object {
243-
private const val T_MAP_API_KEY = "l7xxc7cabdc0790f4cbeacd90982df581610"
244269
private const val MARKER = "marker"
245270
private const val LOT_ADDRESS_TYPE = "A02"
246271
private const val ROAD_ADDRESS_TYPE = "A04"
247272
private const val SAME_POINT = 1
248-
private val NONE_LOCATION = TMapPoint(0.0, 0.0)
249273
val PERMISSIONS = arrayOf(permission.ACCESS_FINE_LOCATION, permission.ACCESS_COARSE_LOCATION)
250274
}
251275
}

presentation/src/main/java/com/stop/ui/nearplace/PlaceSearchFragment.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,19 @@ class PlaceSearchFragment : Fragment() {
4848
logErrorMessage()
4949
}
5050

51-
private fun initAdapter(){
51+
private fun initAdapter() {
5252
nearPlaceAdapter = NearPlaceAdapter()
5353
binding.recyclerViewPlace.adapter = nearPlaceAdapter
5454

5555
nearPlaceAdapter.onItemClick = {
5656
placeSearchViewModel.setClickPlace(it)
57+
placeSearchViewModel.setNearPlaceListEmpty()
5758
binding.root.findNavController().navigate(R.id.action_placeSearchFragment_to_mapFragment)
5859
}
5960
}
6061

61-
private fun buttonClick(){
62-
with(binding){
62+
private fun buttonClick() {
63+
with(binding) {
6364
textViewCurrentLocation.setOnClickListener {
6465
root.findNavController().navigate(R.id.action_placeSearchFragment_to_mapFragment)
6566
}

0 commit comments

Comments
 (0)