-
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.
implemented data,database,model modules
- Loading branch information
1 parent
119ed6e
commit af3acca
Showing
48 changed files
with
1,384 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
plugins { | ||
id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) | ||
id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) | ||
id(BuildPlugins.DAGGER_HILT) | ||
id(BuildPlugins.KSP_PLUGIN) | ||
} | ||
|
||
android { | ||
namespace = "com.lifting.app.core.data" | ||
compileSdk = AppConfig.COMPILE_SDK | ||
|
||
defaultConfig { | ||
minSdk = AppConfig.MIN_SDK | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
dependencies { | ||
api(project(":core:database")) | ||
Kotlin.list.forEach(::api) | ||
|
||
with(Di){ | ||
api(hiltAndroid) | ||
ksp(hiltAndroidCompiler) | ||
ksp(hiltCompiler) | ||
} | ||
} |
Empty file.
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 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
22 changes: 22 additions & 0 deletions
22
core/data/src/main/java/com/lifting/app/core/data/di/RepositoryModule.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,22 @@ | ||
package com.lifting.app.core.data.di | ||
|
||
import com.lifting.app.core.data.repository.exercises.ExercisesRepository | ||
import com.lifting.app.core.data.repository.exercises.ExercisesRepositoryImpl | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
/** | ||
* Created by bedirhansaricayir on 18.07.2024 | ||
*/ | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class RepositoryModule { | ||
|
||
@Binds | ||
internal abstract fun bindsExercisesRepository( | ||
exercisesRepository: ExercisesRepositoryImpl | ||
): ExercisesRepository | ||
} |
37 changes: 37 additions & 0 deletions
37
.../data/src/main/java/com/lifting/app/core/data/repository/exercises/ExercisesRepository.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,37 @@ | ||
package com.lifting.app.core.data.repository.exercises | ||
|
||
import com.lifting.app.core.model.Exercise | ||
import com.lifting.app.core.model.ExerciseCategory | ||
import com.lifting.app.core.model.ExerciseWithInfo | ||
import com.lifting.app.core.model.ExerciseWithMuscle | ||
import com.lifting.app.core.model.LogEntriesWithWorkout | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
/** | ||
* Created by bedirhansaricayir on 15.07.2024 | ||
*/ | ||
|
||
interface ExercisesRepository { | ||
|
||
fun getExercise(exerciseId: String): Flow<Exercise> | ||
|
||
fun getAllExercises(): Flow<List<Exercise>> | ||
|
||
fun getAllExerciseWithInfo(searchQuery: String?): Flow<List<ExerciseWithInfo>> | ||
|
||
fun getAllExercisesWithMuscle(): Flow<List<ExerciseWithMuscle>> | ||
|
||
fun getAllLogEntries(exerciseId: String): Flow<List<LogEntriesWithWorkout>> | ||
|
||
fun getVisibleLogEntries(exerciseId: String): Flow<List<LogEntriesWithWorkout>> | ||
|
||
fun getVisibleLogEntriesCount(exerciseId: String): Flow<Long> | ||
|
||
suspend fun createExercise( | ||
name: String? = null, | ||
notes: String? = null, | ||
primaryMuscleTag: String? = null, | ||
secondaryMuscleTag: String? = null, | ||
category: ExerciseCategory? = null, | ||
) | ||
} |
56 changes: 56 additions & 0 deletions
56
...a/src/main/java/com/lifting/app/core/data/repository/exercises/ExercisesRepositoryImpl.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,56 @@ | ||
package com.lifting.app.core.data.repository.exercises | ||
|
||
import com.lifting.app.core.database.dao.ExercisesDao | ||
import com.lifting.app.core.database.model.ExerciseEntity | ||
import com.lifting.app.core.database.model.ExerciseWithInfoResource | ||
import com.lifting.app.core.database.model.ExerciseWithMuscleResource | ||
import com.lifting.app.core.database.model.LogEntriesWithWorkoutResource | ||
import com.lifting.app.core.database.model.toDomain | ||
import com.lifting.app.core.model.Exercise | ||
import com.lifting.app.core.model.ExerciseCategory | ||
import com.lifting.app.core.model.ExerciseWithInfo | ||
import com.lifting.app.core.model.ExerciseWithMuscle | ||
import com.lifting.app.core.model.LogEntriesWithWorkout | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
import java.util.UUID | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by bedirhansaricayir on 18.07.2024 | ||
*/ | ||
|
||
internal class ExercisesRepositoryImpl @Inject constructor( | ||
private val exercisesDao: ExercisesDao | ||
): ExercisesRepository { | ||
override fun getExercise(exerciseId: String): Flow<Exercise> = exercisesDao.getExercise(exerciseId).map { it.toDomain() } | ||
|
||
override fun getAllExercises(): Flow<List<Exercise>> = exercisesDao.getAllExercises().map { it.map(ExerciseEntity::toDomain)} | ||
|
||
override fun getAllExerciseWithInfo(searchQuery: String?): Flow<List<ExerciseWithInfo>> = exercisesDao.getAllExercisesWithInfo(searchQuery).map { it.map(ExerciseWithInfoResource::toDomain) } | ||
|
||
override fun getAllExercisesWithMuscle(): Flow<List<ExerciseWithMuscle>> = exercisesDao.getAllExercisesWithMuscles().map { it.map(ExerciseWithMuscleResource::toDomain) } | ||
|
||
override fun getAllLogEntries(exerciseId: String): Flow<List<LogEntriesWithWorkout>> = exercisesDao.getAllLogEntries(exerciseId).map { it.map(LogEntriesWithWorkoutResource::toDomain) } | ||
|
||
override fun getVisibleLogEntries(exerciseId: String): Flow<List<LogEntriesWithWorkout>> = exercisesDao.getVisibleLogEntries(exerciseId).map { it.map(LogEntriesWithWorkoutResource::toDomain) } | ||
|
||
override fun getVisibleLogEntriesCount(exerciseId: String): Flow<Long> = exercisesDao.getVisibleLogEntriesCount(exerciseId) | ||
|
||
override suspend fun createExercise( | ||
name: String?, | ||
notes: String?, | ||
primaryMuscleTag: String?, | ||
secondaryMuscleTag: String?, | ||
category: ExerciseCategory? | ||
) = exercisesDao.insertExercise( | ||
ExerciseEntity( | ||
exerciseId = UUID.randomUUID().toString(), | ||
name = name, | ||
notes = notes, | ||
primaryMuscleTag = primaryMuscleTag, | ||
secondaryMuscleTag = secondaryMuscleTag, | ||
category = category, | ||
) | ||
) | ||
} |
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 @@ | ||
/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
plugins { | ||
id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) | ||
id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) | ||
id(BuildPlugins.KSP_PLUGIN) | ||
} | ||
|
||
android { | ||
namespace = "com.lifting.app.core.database" | ||
compileSdk = AppConfig.COMPILE_SDK | ||
|
||
defaultConfig { | ||
minSdk = AppConfig.MIN_SDK | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
isCoreLibraryDesugaringEnabled = true | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
dependencies { | ||
api(project(":core:model")) | ||
|
||
with(Room) { | ||
implementation(room) | ||
implementation(roomRuntime) | ||
ksp(roomCompiler) | ||
} | ||
|
||
with(Di) { | ||
implementation(hiltAndroid) | ||
ksp(hiltCompiler) | ||
ksp(hiltAndroidCompiler) | ||
} | ||
|
||
coreLibraryDesugaring(ThirdParty.desugaring) | ||
} |
Empty file.
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 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
core/database/src/androidTest/java/com/lifting/app/core/database/ExampleInstrumentedTest.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,24 @@ | ||
package com.lifting.app.core.database | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.lifting.app.core.database.test", appContext.packageName) | ||
} | ||
} |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
34 changes: 34 additions & 0 deletions
34
core/database/src/main/java/com/lifting/app/core/database/LiftingDatabase.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,34 @@ | ||
package com.lifting.app.core.database | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
import androidx.room.TypeConverters | ||
import com.lifting.app.core.database.dao.ExercisesDao | ||
import com.lifting.app.core.database.model.ExerciseEntity | ||
import com.lifting.app.core.database.model.ExerciseLogEntryEntity | ||
import com.lifting.app.core.database.model.ExerciseSetGroupNoteEntity | ||
import com.lifting.app.core.database.model.ExerciseWorkoutJunction | ||
import com.lifting.app.core.database.model.MuscleEntity | ||
import com.lifting.app.core.database.model.WorkoutEntity | ||
import com.lifting.app.core.database.util.Converters | ||
|
||
/** | ||
* Created by bedirhansaricayir on 18.07.2024 | ||
*/ | ||
|
||
@Database( | ||
entities = [ | ||
ExerciseEntity::class, | ||
ExerciseLogEntryEntity::class, | ||
ExerciseSetGroupNoteEntity::class, | ||
MuscleEntity::class, | ||
WorkoutEntity::class, | ||
ExerciseWorkoutJunction::class, | ||
], | ||
version = 1, | ||
exportSchema = true | ||
) | ||
@TypeConverters(Converters::class) | ||
internal abstract class LiftingDatabase: RoomDatabase() { | ||
abstract fun exercisesDao(): ExercisesDao | ||
} |
Oops, something went wrong.