Skip to content

Commit 20a54c4

Browse files
committed
Merge remote-tracking branch 'origin/develop' into 22-feature-mission-bus-line
# Conflicts: # data/src/main/java/com/stop/data/di/DataSourceModule.kt # data/src/main/java/com/stop/data/di/RepositoryModule.kt # data/src/main/java/com/stop/data/remote/network/WsBusApiService.kt # domain/src/main/java/com/stop/domain/di/UseCaseModule.kt # presentation/src/main/java/com/stop/ui/map/MapFragment.kt # presentation/src/main/java/com/stop/ui/mission/MissionFragment.kt # presentation/src/main/java/com/stop/ui/mission/TMap.kt # presentation/src/main/res/values/strings.xml
2 parents a4058c7 + b6ddec8 commit 20a54c4

File tree

70 files changed

+1094
-995
lines changed

Some content is hidden

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

70 files changed

+1094
-995
lines changed

data/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ dependencies {
7979
annotationProcessor "androidx.room:room-compiler:2.4.3"
8080
kapt "androidx.room:room-compiler:2.4.3"
8181
implementation "androidx.room:room-ktx:2.4.3"
82+
83+
//DataStore
84+
implementation "androidx.datastore:datastore-preferences:1.0.0"
8285
}
8386

8487
kapt {

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
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
75
import com.stop.data.remote.source.nowlocation.NowLocationRemoteDataSource
@@ -30,12 +28,6 @@ internal interface DataSourceModule {
3028
routeRemoteDataSourceImpl: RouteRemoteDataSourceImpl
3129
): RouteRemoteDataSource
3230

33-
@Binds
34-
@Singleton
35-
fun provideAlarmLocalDataSource(
36-
alarmLocalDataSourceImpl: AlarmLocalDataSourceImpl
37-
): AlarmLocalDataSource
38-
3931
@Binds
4032
@Singleton
4133
fun provideNowLocationRemoteDataSource(
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: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ import dagger.Provides
1111
import dagger.hilt.InstallIn
1212
import dagger.hilt.components.SingletonComponent
1313
import okhttp3.Interceptor
14-
import okhttp3.MediaType.Companion.toMediaTypeOrNull
1514
import okhttp3.OkHttpClient
16-
import okhttp3.Protocol
1715
import okhttp3.Response
18-
import okhttp3.ResponseBody.Companion.toResponseBody
1916
import okhttp3.logging.HttpLoggingInterceptor
2017
import retrofit2.Retrofit
2118
import retrofit2.converter.moshi.MoshiConverterFactory
@@ -31,13 +28,6 @@ internal object NetworkModule {
3128
private const val APIS_KEY_NAME = "ServiceKey"
3229
private const val WS_KEY_NAME = "ServiceKey"
3330

34-
private const val T_MAP_ROUTE_URL = "transit/routes"
35-
36-
/**
37-
* resources에 fake 데이터가 담긴 파일을 넣어줘야 Fake TMap이 정상적으로 동작합니다.
38-
*/
39-
private const val FAKE_JSON_URI = "response.json"
40-
4131
@Provides
4232
@Singleton
4333
fun provideOkHttpClient(
@@ -54,7 +44,7 @@ internal object NetworkModule {
5444
@Provides
5545
@Singleton
5646
fun provideMoshi(): Moshi {
57-
return Moshi.Builder()
47+
return Moshi.Builder()
5848
.addLast(KotlinJsonAdapterFactory())
5949
.build()
6050
}
@@ -144,23 +134,15 @@ internal object NetworkModule {
144134
override fun intercept(chain: Interceptor.Chain): Response {
145135
val url = chain.request().url.toUri().toString()
146136

147-
if (url.contains(T_MAP_ROUTE_URL)) {
148-
val response = readJson(FAKE_JSON_URI)
149-
return chain.proceed(chain.request())
150-
.newBuilder()
151-
.code(200)
152-
.protocol(Protocol.HTTP_2)
153-
.message("success")
154-
.body(
155-
response.toByteArray()
156-
.toResponseBody("application/json".toMediaTypeOrNull())
157-
).addHeader("content-type", "application/json")
158-
.build()
159-
}
160-
161137
val (name: String, key: String) = when {
162-
url.contains(BuildConfig.OPEN_API_SEOUL_URL) -> Pair(OPEN_API_SEOUL_KEY_NAME, BuildConfig.BUS_KEY)
163-
url.contains(BuildConfig.T_MAP_URL) -> Pair(T_MAP_APP_KEY_NAME, BuildConfig.T_MAP_APP_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+
)
164146
url.contains(BuildConfig.APIS_URL) -> Pair(APIS_KEY_NAME, BuildConfig.BUS_KEY)
165147
url.contains(BuildConfig.WS_BUS_URL) -> Pair(WS_KEY_NAME, BuildConfig.BUS_KEY)
166148
else -> {
@@ -175,10 +157,5 @@ internal object NetworkModule {
175157
proceed(newRequest)
176158
}
177159
}
178-
179-
private fun readJson(fileName: String): String {
180-
return Thread.currentThread().contextClassLoader?.getResource(fileName)
181-
?.readText() ?: ""
182-
}
183160
}
184161
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ internal interface RepositoryModule {
2626

2727
@Binds
2828
@Singleton
29-
fun provideNearPlaceRepository(nearPlaceRepositoryImpl: NearPlaceRepositoryImpl): NearPlaceRepository
29+
fun provideNearPlaceRepository(
30+
nearPlaceRepositoryImpl: NearPlaceRepositoryImpl
31+
): NearPlaceRepository
32+
3033

3134
@Binds
3235
@Singleton
@@ -35,4 +38,5 @@ internal interface RepositoryModule {
3538
@Binds
3639
@Singleton
3740
fun provideNowLocationRepository(nowLocationRepositoryImpl: NowLocationRepositoryImpl): NowLocationRepository
41+
3842
}

data/src/main/java/com/stop/data/local/database/dao/AlarmDao.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package com.stop.data.local.database.dao
22

3-
import androidx.room.Database
4-
import androidx.room.RoomDatabase
5-
import com.stop.data.local.entity.AlarmEntity
6-
3+
/*
74
@Database(
8-
entities = [AlarmEntity::class],
5+
entities = [],
96
version = 1
107
)
118
abstract class TroubleShooterApplicationDatabase : RoomDatabase() {
129
13-
abstract fun getAlarmDao(): AlarmDao
14-
1510
companion object {
1611
const val DB_NAME = "TroubleShooter.db"
1712
}
18-
}
13+
}*/

data/src/main/java/com/stop/data/local/entity/AlarmEntity.kt

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.stop.data.local.model
2+
3+
import com.squareup.moshi.JsonClass
4+
import com.stop.data.model.alarm.AlarmRepositoryItem
5+
6+
@JsonClass(generateAdapter = true)
7+
data class Alarm(
8+
val startPosition: String,
9+
val endPosition: String,
10+
val routes: List<String>,
11+
val lastTime: String,
12+
val alarmTime: String,
13+
val alarmMethod: Boolean,
14+
val isMission: Boolean,
15+
) {
16+
17+
fun toRepositoryModel() = AlarmRepositoryItem(
18+
startPosition,
19+
endPosition,
20+
routes,
21+
lastTime,
22+
alarmTime,
23+
alarmMethod,
24+
isMission
25+
)
26+
27+
28+
}

0 commit comments

Comments
 (0)