Skip to content

Commit ba7c18d

Browse files
committed
Merge remote-tracking branch 'origin/develop' into 18-feature-home-bottom-sheet
# Conflicts: # data/build.gradle # data/src/main/java/com/stop/data/local/database/dao/AlarmDao.kt # data/src/main/java/com/stop/data/local/source/alarm/AlarmLocalDataSource.kt # data/src/main/java/com/stop/data/local/source/alarm/AlarmLocalDataSourceImpl.kt # data/src/main/java/com/stop/data/repository/AlarmRepositoryImpl.kt # domain/src/main/java/com/stop/domain/repository/AlarmRepository.kt # domain/src/main/java/com/stop/domain/usecase/alarm/GetAlarmUseCase.kt # domain/src/main/java/com/stop/domain/usecase/alarm/GetAlarmUseCaseImpl.kt # presentation/src/main/java/com/stop/ui/map/MapFragment.kt # presentation/src/main/java/com/stop/ui/placesearch/PlaceSearchViewModel.kt # presentation/src/main/res/layout/fragment_map.xml # presentation/src/main/res/values/strings.xml
2 parents 8fd31c4 + 0387bd7 commit ba7c18d

File tree

122 files changed

+2509
-6367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+2509
-6367
lines changed

build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
buildscript {
22
repositories {
33
google()
4-
mavenCentral()
54
}
65
dependencies {
76
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3"
8-
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.44'
97
}
108
}
119

data/build.gradle

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ plugins {
33
id 'org.jetbrains.kotlin.android'
44
id 'kotlin-kapt'
55
id 'com.google.dagger.hilt.android'
6-
id 'kotlin-android-extensions'
76
}
87

98
Properties properties = new Properties()
@@ -20,8 +19,12 @@ android {
2019
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2120
consumerProguardFiles "consumer-rules.pro"
2221

23-
buildConfigField "String", "TMAP_URL", properties['t_map_url']
24-
buildConfigField("String", "TMAP_APP_KEY", properties['t_map_app_key'])
22+
23+
buildConfigField "String", "T_MAP_URL", properties['t_map_url']
24+
buildConfigField "String", "WS_BUS_URL", properties['ws_bus_url']
25+
buildConfigField "String", "APIS_URL", properties['apis_url']
26+
buildConfigField "String", "OPEN_API_SEOUL_URL", properties['open_api_seoul_url']
27+
buildConfigField "String", "T_MAP_APP_KEY", properties['t_map_app_key']
2528
buildConfigField "String", "SUBWAY_KEY", properties['subway_key']
2629
buildConfigField "String", "BUS_KEY", properties['bus_key']
2730
}
@@ -61,28 +64,24 @@ dependencies {
6164
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
6265

6366
// Moshi
64-
implementation 'com.squareup.moshi:moshi-kotlin:1.13.0'
65-
implementation 'com.squareup.moshi:moshi:1.13.0'
66-
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.13.0'
67-
68-
// Network
69-
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
70-
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
71-
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
7267
implementation 'com.squareup.moshi:moshi-kotlin:1.14.0'
73-
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
74-
implementation 'com.squareup.retrofit2:converter-jaxb:2.9.0'
75-
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
76-
implementation 'com.sun.xml.bind:jaxb-impl:4.0.0'
68+
implementation 'com.squareup.moshi:moshi:1.14.0'
69+
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.14.0'
70+
71+
// xml parser
72+
implementation 'com.tickaroo.tikxml:annotation:0.8.13'
73+
implementation 'com.tickaroo.tikxml:core:0.8.13'
74+
implementation 'com.tickaroo.tikxml:retrofit-converter:0.8.13'
75+
kapt 'com.tickaroo.tikxml:processor:0.8.13'
7776

7877
// Room
7978
implementation "androidx.room:room-runtime:2.4.3"
8079
implementation "androidx.room:room-ktx:2.4.3"
8180
annotationProcessor "androidx.room:room-compiler:2.4.3"
8281
kapt "androidx.room:room-compiler:2.4.3"
8382

84-
// Flow
85-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
83+
//DataStore
84+
implementation "androidx.datastore:datastore-preferences:1.0.0"
8685
}
8786

8887
kapt {

data/src/main/java/com/stop/data/di/ApiModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal object ApiModule {
4545

4646
@Provides
4747
@Singleton
48-
fun providePlaceApiService(@Named("place") retrofit: Retrofit): NearPlaceApiService {
48+
fun providePlaceApiService(@Named("Tmap") retrofit: Retrofit): NearPlaceApiService {
4949
return retrofit.create(NearPlaceApiService::class.java)
5050
}
51-
}
51+
}

data/src/main/java/com/stop/data/di/DataSourceModule.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.stop.data.di
22

3-
import com.stop.data.local.source.alarm.AlarmLocalDataSource
4-
import com.stop.data.local.source.alarm.AlarmLocalDataSourceImpl
53
import com.stop.data.remote.source.nearplace.NearPlaceRemoteDataSource
64
import com.stop.data.remote.source.nearplace.NearPlaceRemoteDataSourceImpl
5+
import com.stop.data.remote.source.nowlocation.NowLocationRemoteDataSource
6+
import com.stop.data.remote.source.nowlocation.NowLocationRemoteDataSourceImpl
77
import com.stop.data.remote.source.route.RouteRemoteDataSource
88
import com.stop.data.remote.source.route.RouteRemoteDataSourceImpl
99
import dagger.Binds
@@ -30,8 +30,8 @@ internal interface DataSourceModule {
3030

3131
@Binds
3232
@Singleton
33-
fun provideAlarmLocalDataSource(
34-
alarmLocalDataSourceImpl: AlarmLocalDataSourceImpl
35-
): AlarmLocalDataSource
33+
fun provideNowLocationRemoteDataSource(
34+
nowLocationRemoteDataSourceImpl: NowLocationRemoteDataSourceImpl
35+
): NowLocationRemoteDataSource
3636

3737
}
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
package com.stop.data.di
22

3-
import android.content.Context
4-
import androidx.room.Room
5-
import com.stop.data.local.database.dao.AlarmDao
6-
import com.stop.data.local.database.dao.TroubleShooterApplicationDatabase
7-
import com.stop.data.local.database.dao.TroubleShooterApplicationDatabase.Companion.DB_NAME
83
import dagger.Module
9-
import dagger.Provides
104
import dagger.hilt.InstallIn
11-
import dagger.hilt.android.qualifiers.ApplicationContext
125
import dagger.hilt.components.SingletonComponent
13-
import javax.inject.Singleton
146

157
@InstallIn(SingletonComponent::class)
168
@Module
179
class DatabaseModule {
1810

19-
@Provides
11+
/* @Provides
2012
@Singleton
2113
fun provideApplicationDatabase(@ApplicationContext context: Context): TroubleShooterApplicationDatabase {
2214
return Room.databaseBuilder(
@@ -25,11 +17,6 @@ class DatabaseModule {
2517
DB_NAME
2618
).fallbackToDestructiveMigration()
2719
.build()
28-
}
20+
}*/
2921

30-
@Provides
31-
@Singleton
32-
fun provideAlarmDao(troubleShooterApplicationDatabase: TroubleShooterApplicationDatabase): AlarmDao {
33-
return troubleShooterApplicationDatabase.getAlarmDao()
34-
}
3522
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.stop.data.di
2+
3+
import android.content.Context
4+
import com.squareup.moshi.Moshi
5+
import com.stop.data.local.source.alarm.AlarmLocalDataSource
6+
import com.stop.data.local.source.alarm.AlarmLocalDataSourceImpl
7+
import dagger.Module
8+
import dagger.Provides
9+
import dagger.hilt.InstallIn
10+
import dagger.hilt.android.qualifiers.ApplicationContext
11+
import dagger.hilt.components.SingletonComponent
12+
import javax.inject.Singleton
13+
14+
@Module
15+
@InstallIn(SingletonComponent::class)
16+
object LocalDataSourceModule {
17+
18+
@Provides
19+
@Singleton
20+
fun provideAlarmLocalDataSource(
21+
@ApplicationContext context: Context,
22+
moshi: Moshi
23+
): AlarmLocalDataSource {
24+
return AlarmLocalDataSourceImpl(
25+
context,
26+
moshi
27+
)
28+
}
29+
30+
}

data/src/main/java/com/stop/data/di/NetworkModule.kt

Lines changed: 23 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@ package com.stop.data.di
33
import com.squareup.moshi.Moshi
44
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
55
import com.stop.data.BuildConfig
6-
import com.stop.data.remote.adapter.route.ResultCallAdapter
6+
import com.stop.data.remote.ResultCallAdapter
7+
import com.tickaroo.tikxml.TikXml
8+
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory
79
import dagger.Module
810
import dagger.Provides
911
import dagger.hilt.InstallIn
1012
import dagger.hilt.components.SingletonComponent
1113
import okhttp3.Interceptor
12-
import okhttp3.MediaType.Companion.toMediaTypeOrNull
1314
import okhttp3.OkHttpClient
14-
import okhttp3.Protocol
1515
import okhttp3.Response
16-
import okhttp3.ResponseBody.Companion.toResponseBody
1716
import okhttp3.logging.HttpLoggingInterceptor
1817
import retrofit2.Retrofit
19-
import retrofit2.converter.jaxb.JaxbConverterFactory
2018
import retrofit2.converter.moshi.MoshiConverterFactory
21-
import java.io.IOException
2219
import javax.inject.Named
2320
import javax.inject.Singleton
2421

@@ -27,23 +24,12 @@ import javax.inject.Singleton
2724
internal object NetworkModule {
2825

2926
private const val T_MAP_APP_KEY_NAME = "appKey"
30-
private const val T_MAP_APP_KEY_VALUE = BuildConfig.TMAP_APP_KEY
31-
private const val T_MAP_URL = "https://apis.openapi.sk.com/"
32-
33-
private const val OPEN_API_SEOUL_URL = "http://openapi.seoul.go.kr:8088/"
3427
private const val OPEN_API_SEOUL_KEY_NAME = "KEY"
35-
private const val BUS_KEY = BuildConfig.BUS_KEY
36-
37-
private const val APIS_URL = "http://apis.data.go.kr/6410000/"
3828
private const val APIS_KEY_NAME = "ServiceKey"
39-
40-
private const val WS_BUS_URL = "http://ws.bus.go.kr/api/rest/"
4129
private const val WS_KEY_NAME = "ServiceKey"
4230

43-
private const val T_MAP_ROUTE_URL = "transit/routes"
44-
private const val FAKE_JSON_URI = "response.json"
45-
4631
@Provides
32+
@Singleton
4733
fun provideOkHttpClient(
4834
customInterceptor: CustomInterceptor,
4935
loggingInterceptor: HttpLoggingInterceptor,
@@ -54,6 +40,7 @@ internal object NetworkModule {
5440
.build()
5541
}
5642

43+
5744
@Provides
5845
@Singleton
5946
fun provideMoshi(): Moshi {
@@ -64,14 +51,8 @@ internal object NetworkModule {
6451

6552
@Provides
6653
@Singleton
67-
fun provideJaxbConverterFactory(): JaxbConverterFactory {
68-
return JaxbConverterFactory.create()
69-
}
70-
71-
@Provides
72-
@Singleton
73-
fun provideTmapInterceptor(): TmapInterceptor {
74-
return TmapInterceptor()
54+
fun provideTikXmlConverterFactory(): TikXmlConverterFactory {
55+
return TikXmlConverterFactory.create(TikXml.Builder().exceptionOnUnreadXml(false).build())
7556
}
7657

7758
@Provides
@@ -89,21 +70,6 @@ internal object NetworkModule {
8970
return ResultCallAdapter.Factory()
9071
}
9172

92-
@Named("place")
93-
@Provides
94-
fun provideRetrofitInstance(
95-
okHttpClient: OkHttpClient,
96-
moshi: Moshi,
97-
resultCallAdapter: ResultCallAdapter.Factory,
98-
): Retrofit {
99-
return Retrofit.Builder()
100-
.baseUrl(T_MAP_URL)
101-
.client(okHttpClient)
102-
.addCallAdapterFactory(resultCallAdapter)
103-
.addConverterFactory(MoshiConverterFactory.create(moshi))
104-
.build()
105-
}
106-
10773
@Provides
10874
@Named("Tmap")
10975
fun provideTmapRetrofitInstance(
@@ -112,7 +78,7 @@ internal object NetworkModule {
11278
resultCallAdapter: ResultCallAdapter.Factory,
11379
): Retrofit {
11480
return Retrofit.Builder()
115-
.baseUrl(T_MAP_URL)
81+
.baseUrl(BuildConfig.T_MAP_URL)
11682
.client(okHttpClient)
11783
.addCallAdapterFactory(resultCallAdapter)
11884
.addConverterFactory(MoshiConverterFactory.create(moshi))
@@ -127,7 +93,7 @@ internal object NetworkModule {
12793
resultCallAdapter: ResultCallAdapter.Factory,
12894
): Retrofit {
12995
return Retrofit.Builder()
130-
.baseUrl(OPEN_API_SEOUL_URL)
96+
.baseUrl(BuildConfig.OPEN_API_SEOUL_URL)
13197
.client(okHttpClient)
13298
.addCallAdapterFactory(resultCallAdapter)
13399
.addConverterFactory(MoshiConverterFactory.create(moshi))
@@ -142,62 +108,43 @@ internal object NetworkModule {
142108
resultCallAdapter: ResultCallAdapter.Factory,
143109
): Retrofit {
144110
return Retrofit.Builder()
145-
.baseUrl(WS_BUS_URL)
111+
.baseUrl(BuildConfig.WS_BUS_URL)
146112
.client(okHttpClient)
147113
.addCallAdapterFactory(resultCallAdapter)
148114
.addConverterFactory(MoshiConverterFactory.create(moshi))
149115
.build()
150116
}
151117

152-
153118
@Provides
154119
@Named("ApisData")
155120
fun provideApisDataRetrofitInstance(
156121
okHttpClient: OkHttpClient,
122+
tikXmlConverterFactory: TikXmlConverterFactory,
157123
resultCallAdapter: ResultCallAdapter.Factory,
158124
): Retrofit {
159125
return Retrofit.Builder()
160-
.baseUrl(APIS_URL)
126+
.baseUrl(BuildConfig.APIS_URL)
161127
.client(okHttpClient)
162128
.addCallAdapterFactory(resultCallAdapter)
129+
.addConverterFactory(tikXmlConverterFactory)
163130
.build()
164131
}
165132

166-
class TmapInterceptor : Interceptor {
167-
@Throws(IOException::class)
168-
override fun intercept(chain: Interceptor.Chain): Response {
169-
return with(chain) {
170-
val newRequest = request().newBuilder()
171-
.addHeader(T_MAP_APP_KEY_NAME, T_MAP_APP_KEY_VALUE)
172-
.build()
173-
proceed(newRequest)
174-
}
175-
}
176-
}
177-
178133
class CustomInterceptor : Interceptor {
179134
override fun intercept(chain: Interceptor.Chain): Response {
180135
val url = chain.request().url.toUri().toString()
181136

182-
if (url.contains(T_MAP_ROUTE_URL)) {
183-
val response = readJson(FAKE_JSON_URI)
184-
return chain.proceed(chain.request())
185-
.newBuilder()
186-
.code(200)
187-
.protocol(Protocol.HTTP_2)
188-
.message("success")
189-
.body(
190-
response.toByteArray()
191-
.toResponseBody("application/json".toMediaTypeOrNull())
192-
).addHeader("content-type", "application/json")
193-
.build()
194-
}
195-
196137
val (name: String, key: String) = when {
197-
url.contains(OPEN_API_SEOUL_URL) -> Pair(OPEN_API_SEOUL_KEY_NAME, BUS_KEY)
198-
url.contains(T_MAP_URL) -> Pair(T_MAP_APP_KEY_NAME, T_MAP_APP_KEY_VALUE)
199-
url.contains(APIS_URL) -> Pair(APIS_KEY_NAME, BUS_KEY)
200-
url.contains(WS_BUS_URL) -> Pair(WS_KEY_NAME, BUS_KEY)
138+
url.contains(BuildConfig.OPEN_API_SEOUL_URL) -> Pair(
139+
OPEN_API_SEOUL_KEY_NAME,
140+
BuildConfig.BUS_KEY
141+
)
142+
url.contains(BuildConfig.T_MAP_URL) -> Pair(
143+
T_MAP_APP_KEY_NAME,
144+
BuildConfig.T_MAP_APP_KEY
145+
)
146+
url.contains(BuildConfig.APIS_URL) -> Pair(APIS_KEY_NAME, BuildConfig.BUS_KEY)
147+
url.contains(BuildConfig.WS_BUS_URL) -> Pair(WS_KEY_NAME, BuildConfig.BUS_KEY)
201148
else -> {
202149
return chain.proceed(chain.request())
203150
}
@@ -210,10 +157,5 @@ internal object NetworkModule {
210157
proceed(newRequest)
211158
}
212159
}
213-
214-
private fun readJson(fileName: String): String {
215-
return Thread.currentThread().contextClassLoader?.getResource(fileName)
216-
?.readText() ?: ""
217-
}
218160
}
219161
}

0 commit comments

Comments
 (0)