-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
core/data/src/main/java/com/yapp/core/data/data/SusuDispatcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.yapp.core.data.data | ||
|
||
import javax.inject.Qualifier | ||
|
||
@Qualifier | ||
annotation class Dispatcher(val susuDispatcher: YappDispatchers) | ||
|
||
enum class YappDispatchers { | ||
IO, | ||
} |
18 changes: 18 additions & 0 deletions
18
core/data/src/main/java/com/yapp/core/data/data/di/DispatchersModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.yapp.core.data.data.di | ||
|
||
import com.yapp.core.data.data.Dispatcher | ||
import com.yapp.core.data.data.YappDispatchers | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.Dispatchers | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object DispatchersModule { | ||
@Provides | ||
@Dispatcher(YappDispatchers.IO) | ||
fun providesIODispatcher(): CoroutineDispatcher = Dispatchers.IO | ||
} |
5 changes: 5 additions & 0 deletions
5
core/data/src/main/java/com/yapp/core/data/local/EntityTable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.yapp.core.data.local | ||
|
||
object EntityTable { | ||
const val POSITION_CONFIG = "positions_configs" | ||
} |
15 changes: 15 additions & 0 deletions
15
core/data/src/main/java/com/yapp/core/data/local/PositionConfigDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.yapp.core.data.local | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
import androidx.room.Upsert | ||
|
||
@Dao | ||
interface PositionConfigDao { | ||
@Query("SELECT * FROM ${EntityTable.POSITION_CONFIG}") | ||
fun getPositionConfigs(): List<PositionConfigEntity> | ||
|
||
@Upsert | ||
fun upsertPositionConfigs(positionConfigs: List<PositionConfigEntity>) | ||
} |
11 changes: 11 additions & 0 deletions
11
core/data/src/main/java/com/yapp/core/data/local/PositionConfigEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.yapp.core.data.local | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = EntityTable.POSITION_CONFIG) | ||
data class PositionConfigEntity( | ||
@PrimaryKey | ||
val name: String, | ||
val label: String, | ||
) |
14 changes: 14 additions & 0 deletions
14
core/data/src/main/java/com/yapp/core/data/local/RoomDataBase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.yapp.core.data.local | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
|
||
@Database( | ||
entities = [ | ||
PositionConfigEntity::class, | ||
], | ||
version = 1, | ||
) | ||
abstract class RoomDataBase : RoomDatabase() { | ||
abstract fun positionConfigDao(): PositionConfigDao | ||
} |
17 changes: 17 additions & 0 deletions
17
core/data/src/main/java/com/yapp/core/data/local/di/DaoModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.yapp.core.data.local.di | ||
|
||
import com.yapp.core.data.local.RoomDataBase | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object DaoModule { | ||
|
||
@Singleton | ||
@Provides | ||
fun providePositionDao(db: RoomDataBase) = db.positionConfigDao() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
core/data/src/main/java/com/yapp/core/data/local/di/RoomModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.yapp.core.data.local.di | ||
|
||
import android.content.Context | ||
import androidx.room.Room | ||
import com.yapp.core.data.local.RoomDataBase | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object RoomModule { | ||
|
||
private const val DB_NAME = "database-yapp" | ||
|
||
@Provides | ||
@Singleton | ||
fun provideRoomDataBase( | ||
@ApplicationContext context: Context, | ||
) = Room.databaseBuilder( | ||
context, | ||
RoomDataBase::class.java, | ||
DB_NAME, | ||
).build() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters