Skip to content

Commit 5a5c8a5

Browse files
Merge branch 'develop' into 25-feature-get-seoul-bus-last-time
2 parents d75e6a5 + 92a7b7e commit 5a5c8a5

Some content is hidden

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

42 files changed

+705
-241
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.route.RouteRemoteDataSource
@@ -28,10 +26,4 @@ internal interface DataSourceModule {
2826
routeRemoteDataSourceImpl: RouteRemoteDataSourceImpl
2927
): RouteRemoteDataSource
3028

31-
@Binds
32-
@Singleton
33-
fun provideAlarmLocalDataSource(
34-
alarmLocalDataSourceImpl: AlarmLocalDataSourceImpl
35-
): AlarmLocalDataSource
36-
3729
}
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/RepositoryModule.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ internal interface RepositoryModule {
2424

2525
@Binds
2626
@Singleton
27-
fun provideNearPlaceRepository(nearPlaceRepositoryImpl: NearPlaceRepositoryImpl): NearPlaceRepository
27+
fun provideNearPlaceRepository(
28+
nearPlaceRepositoryImpl: NearPlaceRepositoryImpl
29+
): NearPlaceRepository
30+
2831

2932
@Binds
3033
@Singleton
3134
fun provideAlarmRepository(alarmRepositoryImpl: AlarmRepositoryImpl): AlarmRepository
35+
3236
}

โ€Ž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+
}

โ€Ždata/src/main/java/com/stop/data/local/source/alarm/AlarmLocalDataSource.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import kotlinx.coroutines.flow.Flow
55

66
interface AlarmLocalDataSource {
77

8-
fun insertAlarm(alarmRepositoryItem: AlarmRepositoryItem)
8+
suspend fun saveAlarm(alarmRepositoryItem: AlarmRepositoryItem)
99

10-
fun deleteAlarm()
10+
suspend fun deleteAlarm()
1111

12-
fun selectAlarm(): Flow<AlarmRepositoryItem>
12+
suspend fun getAlarm(): Flow<AlarmRepositoryItem?>
1313

1414
}

0 commit comments

Comments
ย (0)