Skip to content

Commit a08a949

Browse files
authored
Merge pull request #39 from boostcampwm-2022/16-feature-click
[PR] ์žฅ์†Œ ๊ฒ€์ƒ‰ํ•œ ์•„์ดํ…œ ํด๋ฆญ ์‹œ viewModel ์ €์žฅํ•ด์„œ MapFragment์—์„œ ๊ด€์ธก ํ›„ ๋งˆ์ปค ๋ฐ ํŒจ๋„ ์ด๋™ ๊ตฌํ˜„
2 parents 8fad131 + ad82dec commit a08a949

File tree

22 files changed

+168
-165
lines changed

22 files changed

+168
-165
lines changed

โ€Ždata/src/main/java/com/stop/data/model/nearplace/Place.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ import com.stop.domain.model.nearplace.Place
44

55
data class Place(
66
val name: String,
7-
val radius : String,
8-
val roadAddressList: List<RoadAddress>
7+
val radius: String,
8+
val fullAddressRoad: String,
9+
val centerLat: Double,
10+
val centerLon: Double
911
) {
1012

1113
fun toUseCaseModel() = Place(
1214
name = name,
1315
radius = radius,
14-
roadAddressList = roadAddressList.map {
15-
it.toDomainRoadAddress()
16-
}
16+
fullAddressRoad = fullAddressRoad,
17+
centerLat = centerLat,
18+
centerLon = centerLon
1719
)
1820
}

โ€Ždata/src/main/java/com/stop/data/model/nearplace/RoadAddress.kt

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

โ€Ždata/src/main/java/com/stop/data/remote/model/nearplace/Poi.kt

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.stop.data.remote.model.nearplace
22

33
import com.squareup.moshi.JsonClass
44
import com.stop.data.model.nearplace.Place
5-
import com.stop.data.model.nearplace.RoadAddress
65

76
@JsonClass(generateAdapter = true)
87
data class Poi(
@@ -43,24 +42,13 @@ data class Poi(
4342
) {
4443

4544
fun toRepositoryModel(): Place {
46-
val roadAddressList = newAddressList.newAddress.map {
47-
RoadAddress(
48-
it.bldNo1,
49-
it.bldNo2,
50-
it.centerLat.toFloat(),
51-
it.centerLon.toFloat(),
52-
it.frontLat.toFloat(),
53-
it.frontLon.toFloat(),
54-
it.fullAddressRoad,
55-
it.roadId,
56-
it.roadName
57-
)
58-
}
59-
45+
val road = newAddressList.newAddress.firstOrNull()
6046
return Place(
61-
name,
62-
radius,
63-
roadAddressList
47+
name = name,
48+
radius = radius,
49+
fullAddressRoad = road?.fullAddressRoad ?: "",
50+
centerLat = road?.centerLat?.toDouble() ?: 0.0,
51+
centerLon = road?.centerLon?.toDouble() ?: 0.0
6452
)
6553
}
6654

โ€Ž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: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package com.stop.data.repository
33
import com.stop.data.remote.source.nearplace.NearPlaceRemoteDataSource
44
import com.stop.domain.model.nearplace.Place
55
import com.stop.domain.repository.NearPlaceRepository
6+
import kotlinx.coroutines.flow.Flow
7+
import kotlinx.coroutines.flow.flow
68
import javax.inject.Inject
79

810
internal class NearPlaceRepositoryImpl @Inject constructor(
@@ -12,13 +14,21 @@ internal class NearPlaceRepositoryImpl @Inject constructor(
1214
override suspend fun getNearPlaces(
1315
version: Int,
1416
searchKeyword: String,
15-
centerLon: Float,
16-
centerLat: Float,
17+
centerLon: Double,
18+
centerLat: Double,
1719
appKey: String
18-
): List<Place> {
19-
return nearPlaceRemoteDataSource.getNearPlaces(
20-
version, searchKeyword, centerLon, centerLat, appKey
21-
).map { it.toUseCaseModel() }
20+
): Flow<List<Place>> = flow<List<Place>> {
21+
emit(
22+
nearPlaceRemoteDataSource.getNearPlaces(
23+
version,
24+
searchKeyword,
25+
centerLon,
26+
centerLat,
27+
appKey
28+
).map {
29+
it.toUseCaseModel()
30+
}
31+
)
2232
}
2333

2434
}

โ€Ždomain/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ java {
1010
}
1111

1212
dependencies {
13-
//Hilt
13+
// Hilt
1414
implementation 'com.google.dagger:hilt-core:2.44'
1515
kapt 'com.google.dagger:hilt-compiler:2.44'
16+
17+
// Flow
18+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
1619
}

โ€Ždomain/src/main/java/com/stop/domain/model/nearplace/Place.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package com.stop.domain.model.nearplace
22

33
data class Place(
44
val name: String,
5-
val radius : String,
6-
val roadAddressList: List<RoadAddress>
5+
val radius: String,
6+
val fullAddressRoad: String,
7+
val centerLat: Double,
8+
val centerLon: Double
79
)

โ€Ždomain/src/main/java/com/stop/domain/model/nearplace/RoadAddress.kt

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

0 commit comments

Comments
ย (0)