-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
29ea75c
commit ce3b5b6
Showing
18 changed files
with
335 additions
and
89 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
core/common/src/main/java/com/brandyodhiambo/common/domain/model/TimeFormate.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.brandyodhiambo.common.domain.model | ||
|
||
data class TimeFormate( | ||
val formate:Int | ||
) |
11 changes: 11 additions & 0 deletions
11
...common/src/main/java/com/brandyodhiambo/common/domain/repository/TimeFormateRepository.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.brandyodhiambo.common.domain.repository | ||
|
||
import androidx.lifecycle.LiveData | ||
import com.brandyodhiambo.common.domain.model.TimeFormate | ||
|
||
interface TimeFormateRepository { | ||
|
||
suspend fun insertTimeFormate(timeFormate: TimeFormate) | ||
fun getTimeFormate(): LiveData<TimeFormate?> | ||
suspend fun deleteTimeFormate(timeFormate: TimeFormate) | ||
} |
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
21 changes: 21 additions & 0 deletions
21
core/database/src/main/java/com/brandyodhiambo/dao/TimeFormateDao.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,21 @@ | ||
package com.brandyodhiambo.dao | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
import com.brandyodhiambo.entity.TimeFormateEntity | ||
|
||
@Dao | ||
interface TimeFormateDao { | ||
|
||
@Insert | ||
suspend fun insertTimeFormate(timeFormateEntity: TimeFormateEntity) | ||
|
||
@Query("SELECT * FROM time_formate_table") | ||
fun getTimeFormate():LiveData<TimeFormateEntity> | ||
|
||
@Delete | ||
suspend fun deleteTimeFormate(timeFormateEntity: TimeFormateEntity) | ||
} |
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
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
12 changes: 12 additions & 0 deletions
12
core/database/src/main/java/com/brandyodhiambo/entity/TimeFormateEntity.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,12 @@ | ||
package com.brandyodhiambo.entity | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import com.brandyodhiambo.Constants.TIME_FORMATE_TABLE | ||
|
||
@Entity(tableName = TIME_FORMATE_TABLE) | ||
data class TimeFormateEntity( | ||
@PrimaryKey(autoGenerate = true) | ||
val id: Int = 0, | ||
val formate: Int, | ||
) |
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
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
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
16 changes: 16 additions & 0 deletions
16
feature/settings/src/main/java/com/brandyodhiambo/settings/data/mapper/Mapper.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,16 @@ | ||
package com.brandyodhiambo.settings.data.mapper | ||
|
||
import com.brandyodhiambo.common.domain.model.TimeFormate | ||
import com.brandyodhiambo.entity.TimeFormateEntity | ||
|
||
internal fun TimeFormateEntity.toTimeFormate(): TimeFormate { | ||
return TimeFormate( | ||
formate = formate | ||
) | ||
} | ||
|
||
internal fun TimeFormate.toTimeFormateEntity(): TimeFormateEntity { | ||
return TimeFormateEntity( | ||
formate = formate | ||
) | ||
} |
27 changes: 27 additions & 0 deletions
27
...gs/src/main/java/com/brandyodhiambo/settings/data/repository/TimeFormateRepositoryImpl.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,27 @@ | ||
package com.brandyodhiambo.settings.data.repository | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.map | ||
import com.brandyodhiambo.common.domain.model.TimeFormate | ||
import com.brandyodhiambo.common.domain.repository.TimeFormateRepository | ||
import com.brandyodhiambo.dao.TimeFormateDao | ||
import com.brandyodhiambo.settings.data.mapper.toTimeFormate | ||
import com.brandyodhiambo.settings.data.mapper.toTimeFormateEntity | ||
|
||
class TimeFormateRepositoryImpl( | ||
private val timeFormateDao: TimeFormateDao | ||
):TimeFormateRepository { | ||
override suspend fun insertTimeFormate(timeFormate: TimeFormate) { | ||
timeFormateDao.insertTimeFormate(timeFormate.toTimeFormateEntity()) | ||
} | ||
|
||
override fun getTimeFormate(): LiveData<TimeFormate?> { | ||
return timeFormateDao.getTimeFormate().map { | ||
it.toTimeFormate() | ||
} | ||
} | ||
|
||
override suspend fun deleteTimeFormate(timeFormate: TimeFormate) { | ||
timeFormateDao.deleteTimeFormate(timeFormate.toTimeFormateEntity()) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
feature/settings/src/main/java/com/brandyodhiambo/settings/di/SettingModule.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,20 @@ | ||
package com.brandyodhiambo.settings.di | ||
|
||
import com.brandyodhiambo.common.domain.repository.TimeFormateRepository | ||
import com.brandyodhiambo.dao.TimeFormateDao | ||
import com.brandyodhiambo.settings.data.repository.TimeFormateRepositoryImpl | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object SettingModule { | ||
@Provides | ||
@Singleton | ||
fun provideTimeFormateRepository(timeFormateDao: TimeFormateDao):TimeFormateRepository{ | ||
return TimeFormateRepositoryImpl(timeFormateDao) | ||
} | ||
} |
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
Oops, something went wrong.