Skip to content

Commit d92c349

Browse files
committed
Merge branch 'develop' into 75-feature-alarm-modify
# Conflicts: # presentation/src/main/java/com/stop/ui/alarmsetting/AlarmSettingViewModel.kt # presentation/src/main/java/com/stop/ui/map/MapFragment.kt # presentation/src/main/res/layout/fragment_alarm_start.xml
2 parents ba6c57c + 542dc0f commit d92c349

40 files changed

+624
-550
lines changed

โ€Ždata/src/main/java/com/stop/data/di/ApiModule.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ internal object ApiModule {
1919
return retrofit.create(TmapApiService::class.java)
2020
}
2121

22-
@Provides
23-
@Singleton
24-
fun provideFakeTmapApiService(@Named("Tmap") retrofit: Retrofit): FakeTmapApiService {
25-
return retrofit.create(FakeTmapApiService::class.java)
26-
}
27-
2822
@Provides
2923
@Singleton
3024
fun provideOpenApiSeoulService(@Named("OpenApiSeoul") retrofit: Retrofit): OpenApiSeoulService {

โ€Ždata/src/main/java/com/stop/data/remote/model/nowlocation/bus/BusBody.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import com.stop.domain.model.nowlocation.BusCurrentInformation
55

66
data class BusBody(
77
@Json(name = "itemList")
8-
val busCurrentInformation: List<BusCurrentInformation>
8+
val busCurrentInformation: List<BusCurrentInformation>?
99
)

โ€Ždata/src/main/java/com/stop/data/remote/model/nowlocation/subway/SubwayTrainNowLocationResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import com.squareup.moshi.JsonClass
66
@JsonClass(generateAdapter = true)
77
data class SubwayTrainNowLocationResponse(
88
@Json(name = "realtimePositionList")
9-
val realtimePositions: List<TrainLocationInfo>
9+
val realtimePositions: List<TrainLocationInfo>?
1010
)

โ€Ždata/src/main/java/com/stop/data/remote/model/route/gyeonggi/GyeonggiBusLastTimeResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ import com.tickaroo.tikxml.annotation.Xml
88
internal data class GyeonggiBusLastTimeResponse(
99
@Path("msgBody")
1010
@Element(name = "busRouteInfoItem")
11-
val lastTimes: List<GyeonggiBusLastTime>?
11+
val lastTimes: List<GyeonggiBusLastTime>
1212
)

โ€Ždata/src/main/java/com/stop/data/remote/network/FakeTmapApiService.kt

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

โ€Ždata/src/main/java/com/stop/data/remote/source/nowlocation/NowLocationRemoteDataSourceImpl.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.stop.data.remote.source.nowlocation
22

3+
import com.squareup.moshi.JsonDataException
34
import com.stop.data.remote.model.NetworkResult
45
import com.stop.domain.model.nowlocation.BusCurrentInformation
56
import com.stop.data.remote.model.nowlocation.subway.TrainLocationInfo
@@ -16,6 +17,7 @@ internal class NowLocationRemoteDataSourceImpl @Inject constructor(
1617
with(wsBusApiService.getBusNowLocation(busRouteId = busRouteId)) {
1718
return when (this) {
1819
is NetworkResult.Success -> data.busBody.busCurrentInformation
20+
?: throw JsonDataException(NO_RESULT)
1921
is NetworkResult.Failure -> throw IllegalArgumentException(message)
2022
is NetworkResult.NetworkError -> throw exception
2123
is NetworkResult.Unexpected -> throw exception
@@ -27,6 +29,7 @@ internal class NowLocationRemoteDataSourceImpl @Inject constructor(
2729
with(swOpenApiSeoulService.getSubwayTrainNowStationInfo(stationName = subwayNumber.toString() + LINE)) {
2830
return when (this) {
2931
is NetworkResult.Success -> data.realtimePositions
32+
?: throw JsonDataException(NO_RESULT)
3033
is NetworkResult.Failure -> throw IllegalArgumentException(message)
3134
is NetworkResult.NetworkError -> throw exception
3235
is NetworkResult.Unexpected -> throw exception
@@ -36,6 +39,7 @@ internal class NowLocationRemoteDataSourceImpl @Inject constructor(
3639

3740
companion object {
3841
private const val LINE = "ํ˜ธ์„ "
42+
private const val NO_RESULT = "๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."
3943
}
4044

4145
}

โ€Ždata/src/main/java/com/stop/data/remote/source/route/RouteRemoteDataSource.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ internal interface RouteRemoteDataSource {
2929

3030
suspend fun getSeoulBusStationArsId(stationName: String): List<BusStationInfo>
3131
suspend fun getSeoulBusRoute(stationId: String): List<BusRouteInfo>
32-
suspend fun getSeoulBusLastTime(stationId: String, lineId: String): List<LastTimeInfo>?
32+
suspend fun getSeoulBusLastTime(stationId: String, lineId: String): List<LastTimeInfo>
3333

3434
suspend fun getGyeonggiBusStationId(stationName: String): List<GyeonggiBusStation>
3535
suspend fun getGyeonggiBusRoute(stationId: String): List<GyeonggiBusRoute>
36-
suspend fun getGyeonggiBusLastTime(lineId: String): List<GyeonggiBusLastTime>?
36+
suspend fun getGyeonggiBusLastTime(lineId: String): List<GyeonggiBusLastTime>
3737
suspend fun getGyeonggiBusRouteStations(lineId: String): List<GyeonggiBusStation>
3838
}

โ€Ždata/src/main/java/com/stop/data/remote/source/route/RouteRemoteDataSourceImpl.kt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import javax.inject.Inject
2020

2121
internal class RouteRemoteDataSourceImpl @Inject constructor(
2222
private val tMapApiService: TmapApiService,
23-
// private val fakeTmapApiService: FakeTmapApiService,
2423
private val openApiSeoulService: OpenApiSeoulService,
2524
private val wsBusApiService: WsBusApiService,
2625
private val apisDataService: ApisDataService,
@@ -33,7 +32,7 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
3332
return when (this) {
3433
is NetworkResult.Success -> {
3534
val itineraries = this.data.metaData?.plan?.itineraries
36-
?: throw JsonDataException(NO_ROUTE_RESULT)
35+
?: throw JsonDataException(NO_RESULT)
3736
eraseDuplicateLeg(itineraries)
3837
}
3938
is NetworkResult.Failure -> throw IllegalArgumentException(this.message)
@@ -90,7 +89,8 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
9089
)
9190
) {
9291
return when (this) {
93-
is NetworkResult.Success -> this.data.searchStationNameBySubwayLineInfo.stations
92+
is NetworkResult.Success -> this.data.searchStationNameBySubwayLineInfo?.stations
93+
?: throw JsonDataException(NO_RESULT)
9494
is NetworkResult.Failure -> throw IllegalArgumentException(this.message)
9595
is NetworkResult.NetworkError -> throw this.exception
9696
is NetworkResult.Unexpected -> throw this.exception
@@ -116,7 +116,8 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
116116
)
117117
) {
118118
return when (this) {
119-
is NetworkResult.Success -> this.data.searchLastTrainTimeByIDService.stationLastTimes
119+
is NetworkResult.Success -> this.data.searchLastTrainTimeByIDService?.stationLastTimes
120+
?: throw JsonDataException(NO_RESULT)
120121
is NetworkResult.Failure -> throw IllegalArgumentException(this.message)
121122
is NetworkResult.NetworkError -> throw this.exception
122123
is NetworkResult.Unexpected -> throw this.exception
@@ -128,6 +129,7 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
128129
with(wsBusApiService.getBusArsId(stationName)) {
129130
return when (this) {
130131
is NetworkResult.Success -> this.data.arsIdMsgBody.busStations
132+
?: throw JsonDataException(NO_RESULT)
131133
is NetworkResult.Failure -> throw IllegalArgumentException(this.message)
132134
is NetworkResult.NetworkError -> throw this.exception
133135
is NetworkResult.Unexpected -> throw this.exception
@@ -139,6 +141,7 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
139141
with(wsBusApiService.getBusRoute(stationId)) {
140142
return when (this) {
141143
is NetworkResult.Success -> this.data.routeIdMsgBody.busRoutes
144+
?: throw JsonDataException(NO_RESULT)
142145
is NetworkResult.Failure -> throw IllegalArgumentException(this.message)
143146
is NetworkResult.NetworkError -> throw this.exception
144147
is NetworkResult.Unexpected -> throw this.exception
@@ -149,10 +152,11 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
149152
override suspend fun getSeoulBusLastTime(
150153
stationId: String,
151154
lineId: String
152-
): List<LastTimeInfo>? {
155+
): List<LastTimeInfo> {
153156
with(wsBusApiService.getBusLastTime(stationId, lineId)) {
154157
return when (this) {
155158
is NetworkResult.Success -> this.data.lastTimeMsgBody.lastTimes
159+
?: throw JsonDataException(NO_RESULT)
156160
is NetworkResult.Failure -> throw IllegalArgumentException(this.message)
157161
is NetworkResult.NetworkError -> throw this.exception
158162
is NetworkResult.Unexpected -> throw this.exception
@@ -182,10 +186,10 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
182186
}
183187
}
184188

185-
override suspend fun getGyeonggiBusLastTime(lineId: String): List<GyeonggiBusLastTime>? {
189+
override suspend fun getGyeonggiBusLastTime(lineId: String): List<GyeonggiBusLastTime> {
186190
with(apisDataService.getBusLastTime(lineId)) {
187191
return when (this) {
188-
is NetworkResult.Success -> this.data.lastTimes?.map { it.toDomain() }
192+
is NetworkResult.Success -> this.data.lastTimes.map { it.toDomain() }
189193
is NetworkResult.Failure -> throw IllegalArgumentException(this.message)
190194
is NetworkResult.NetworkError -> throw this.exception
191195
is NetworkResult.Unexpected -> throw this.exception
@@ -244,13 +248,15 @@ internal class RouteRemoteDataSourceImpl @Inject constructor(
244248
}
245249

246250
private fun findStationCd(stationId: String, data: SubwayStationResponse): String {
247-
return data.searchInfoBySubwayNameService.row.firstOrNull {
251+
val searchInfoBySubwayNameService = data.searchInfoBySubwayNameService
252+
?: throw JsonDataException(NO_RESULT)
253+
return searchInfoBySubwayNameService.row.firstOrNull {
248254
it.frCode == stationId
249255
}?.stationCd ?: throw IllegalArgumentException(NO_SUBWAY_STATION)
250256
}
251257

252258
companion object {
253259
private const val NO_SUBWAY_STATION = "ํ•ด๋‹นํ•˜๋Š” ์ง€ํ•˜์ฒ ์—ญ์ด ์—†์Šต๋‹ˆ๋‹ค."
254-
private const val NO_ROUTE_RESULT = "๊ฒฝ๋กœ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."
260+
private const val NO_RESULT = "๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."
255261
}
256262
}

โ€Ždata/src/main/java/com/stop/data/repository/RouteRepositoryImpl.kt

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,31 @@ internal class RouteRepositoryImpl @Inject constructor(
3737
}
3838

3939
override suspend fun getSubwayStationCd(stationId: String, stationName: String): String {
40-
return remoteDataSource.getSubwayStationCd(stationId, stationName)
40+
return try {
41+
remoteDataSource.getSubwayStationCd(stationId, stationName)
42+
} catch (exception: JsonDataException) {
43+
""
44+
}
4145
}
4246

4347
override suspend fun getSubwayStations(lineName: String): List<Station> {
44-
return remoteDataSource.getSubwayStations(lineName)
48+
return try {
49+
remoteDataSource.getSubwayStations(lineName)
50+
} catch (exception: JsonDataException) {
51+
listOf()
52+
}
4553
}
4654

4755
override suspend fun getSubwayStationLastTime(
4856
stationId: String,
4957
transportDirectionType: TransportDirectionType,
5058
weekType: WeekType,
5159
): List<StationLastTime> {
52-
return remoteDataSource.getSubwayStationLastTime(stationId, transportDirectionType, weekType)
60+
return try {
61+
remoteDataSource.getSubwayStationLastTime(stationId, transportDirectionType, weekType)
62+
} catch (exception: JsonDataException) {
63+
listOf()
64+
}
5365
}
5466

5567
override suspend fun getSubwayRoute(
@@ -78,30 +90,58 @@ internal class RouteRepositoryImpl @Inject constructor(
7890
}
7991

8092
override suspend fun getSeoulBusStationArsId(stationName: String): List<BusStationInfo> {
81-
return remoteDataSource.getSeoulBusStationArsId(stationName)
93+
return try {
94+
remoteDataSource.getSeoulBusStationArsId(stationName)
95+
} catch (exception: JsonDataException) {
96+
listOf()
97+
}
8298
}
8399

84100
override suspend fun getSeoulBusRoute(stationId: String): List<BusRouteInfo> {
85-
return remoteDataSource.getSeoulBusRoute(stationId)
101+
return try {
102+
remoteDataSource.getSeoulBusRoute(stationId)
103+
} catch (exception: JsonDataException) {
104+
listOf()
105+
}
86106
}
87107

88-
override suspend fun getSeoulBusLastTime(stationId: String, lineId: String): List<LastTimeInfo>? {
89-
return remoteDataSource.getSeoulBusLastTime(stationId, lineId)
108+
override suspend fun getSeoulBusLastTime(stationId: String, lineId: String): List<LastTimeInfo> {
109+
return try{
110+
remoteDataSource.getSeoulBusLastTime(stationId, lineId)
111+
} catch (exception: JsonDataException) {
112+
listOf()
113+
}
90114
}
91115

92116
override suspend fun getGyeonggiBusStationId(stationName: String): List<GyeonggiBusStation> {
93-
return remoteDataSource.getGyeonggiBusStationId(stationName)
117+
return try {
118+
remoteDataSource.getGyeonggiBusStationId(stationName)
119+
} catch (exception: NullPointerException) {
120+
listOf()
121+
}
94122
}
95123

96124
override suspend fun getGyeonggiBusRoute(stationId: String): List<GyeonggiBusRoute> {
97-
return remoteDataSource.getGyeonggiBusRoute(stationId)
125+
return try {
126+
remoteDataSource.getGyeonggiBusRoute(stationId)
127+
} catch (exception: NullPointerException) {
128+
listOf()
129+
}
98130
}
99131

100-
override suspend fun getGyeonggiBusLastTime(lineId: String): List<GyeonggiBusLastTime>? {
101-
return remoteDataSource.getGyeonggiBusLastTime(lineId)
132+
override suspend fun getGyeonggiBusLastTime(lineId: String): List<GyeonggiBusLastTime> {
133+
return try {
134+
remoteDataSource.getGyeonggiBusLastTime(lineId)
135+
} catch (exception: NullPointerException) {
136+
listOf()
137+
}
102138
}
103139

104140
override suspend fun getGyeonggiBusRouteStations(lineId: String): List<GyeonggiBusStation> {
105-
return remoteDataSource.getGyeonggiBusRouteStations(lineId)
141+
return try {
142+
remoteDataSource.getGyeonggiBusRouteStations(lineId)
143+
} catch (exception: NullPointerException) {
144+
listOf()
145+
}
106146
}
107147
}

โ€Ždomain/src/main/java/com/stop/domain/model/route/seoul/bus/ArsIdMsgBody.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import com.squareup.moshi.JsonClass
66
@JsonClass(generateAdapter = true)
77
data class ArsIdMsgBody(
88
@Json(name = "itemList")
9-
val busStations: List<BusStationInfo>
9+
val busStations: List<BusStationInfo>?
1010
)

0 commit comments

Comments
ย (0)