Skip to content

Commit

Permalink
14.06.2023
Browse files Browse the repository at this point in the history
-исправлен баг с переносом класса в domain(баг был из-за старой ссылки в nav graph)
-заменен kapt на ksp
-сдела небольшой рефакторинг пакетов

Tasks:

-перевести таймер на чистую архитектуру

-подумать над тем, чтобы сделать мульти таймеровое приложение, т.е. сделать возможность прекращать тренировку, а также пускать её на заднем фоне с кнопкой континью и минитаймером вместо start workout. Так можно будет вести несколько тренировок, но надо будет делать фабрики вместо синглов в дата слое и что-то придумать со звуками( в целом спорная фича)

-почистить код от мусора(старого кода, лишних картинок, стрингов и тд)

-сделать выбор при нажатии назад(отменить тренировку или нет) поменять кнопку старт на главной с старт на котинью
  • Loading branch information
alexxk2 committed Jun 14, 2023
1 parent fe32d50 commit 91af70d
Show file tree
Hide file tree
Showing 25 changed files with 46 additions and 208 deletions.
8 changes: 5 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ plugins {
id 'kotlin-parcelize'
// Navigation
id 'androidx.navigation.safeargs.kotlin'
//Kotlin annotation processing tool for Room
id 'kotlin-kapt'
//Kotlin symbol processing for Room
id("com.google.devtools.ksp")

}

android {
Expand Down Expand Up @@ -69,7 +70,8 @@ dependencies {
// Room libraries
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
//Kotlin symbol processing for Room
ksp "androidx.room:room-compiler:$room_version"
//Koin
implementation "io.insert-koin:koin-core:$koin_version"
implementation "io.insert-koin:koin-android:$koin_version"
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/practice/getup/data/db/WorkoutDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import kotlinx.coroutines.flow.Flow
@Dao
interface WorkoutDao {
@Insert(onConflict = OnConflictStrategy.IGNORE)
suspend fun insert(workout: WorkoutDto)
suspend fun insert(workoutDto: WorkoutDto)

@Update
suspend fun update(workout: WorkoutDto)
suspend fun update(workoutDto: WorkoutDto)

@Delete
suspend fun delete(workout: WorkoutDto)
suspend fun delete(workoutDto: WorkoutDto)

@Query("SELECT * FROM workout ORDER BY name ASC")
fun getAll(): Flow<List<WorkoutDto>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.practice.getup.data.db.dto.WorkoutDto
import com.practice.getup.database.Workout

@Database(entities = [WorkoutDto::class], version = 1, exportSchema = false)
abstract class WorkoutDatabase() : RoomDatabase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.practice.getup.data.repositories.impl

import com.practice.getup.data.db.RoomStorage
import com.practice.getup.data.db.dto.WorkoutDto
import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import com.practice.getup.domain.repositories.StorageRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -59,7 +59,7 @@ class StorageRepositoryImpl(private val roomStorage: RoomStorage): StorageReposi
}
}

private fun mapToDomain(workoutDto: WorkoutDto): Workout{
private fun mapToDomain(workoutDto: WorkoutDto): Workout {

with(workoutDto) {
return Workout(
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/java/com/practice/getup/database/Workout.kt

This file was deleted.

14 changes: 14 additions & 0 deletions app/src/main/java/com/practice/getup/domain/models/Workout.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.practice.getup.domain.models

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class Workout(
val id: Int = 0,
val name: String,
val preparingTime: Int,
val workTime: Int,
val restTime: Int,
val numberOfSets: Int
): Parcelable
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.practice.getup.domain.repositories

import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import kotlinx.coroutines.flow.Flow

interface StorageRepository {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.practice.getup.domain.storage

import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import com.practice.getup.domain.repositories.StorageRepository

class AddNewWorkoutUseCase(private val storageRepository: StorageRepository) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.practice.getup.domain.storage

import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import com.practice.getup.domain.repositories.StorageRepository

class DeleteWorkoutUseCase(private val storageRepository: StorageRepository) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.practice.getup.domain.storage

import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import com.practice.getup.domain.repositories.StorageRepository
import kotlinx.coroutines.flow.Flow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.practice.getup.domain.storage

import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import com.practice.getup.domain.repositories.StorageRepository
import kotlinx.coroutines.flow.Flow

class GetWorkoutUseCase(private val storageRepository: StorageRepository) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.practice.getup.domain.storage

import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import com.practice.getup.domain.repositories.StorageRepository

class UpdateWorkoutUseCase(private val storageRepository: StorageRepository) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import androidx.navigation.fragment.findNavController
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.practice.getup.R
import com.practice.getup.database.Workout
import com.practice.getup.databinding.FragmentOptionsBinding
import com.practice.getup.domain.models.Workout
import com.practice.getup.presentation.edit.view_model.OptionsViewModel
import org.koin.androidx.viewmodel.ext.android.viewModel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import com.practice.getup.domain.storage.AddNewWorkoutUseCase
import com.practice.getup.domain.storage.DeleteWorkoutUseCase
import com.practice.getup.domain.storage.GetWorkoutUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.practice.getup.R
import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import com.practice.getup.databinding.WorkoutListItemBinding


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.navigation.NavDirections
import androidx.navigation.fragment.findNavController
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.practice.getup.app.App
import com.practice.getup.R
import com.practice.getup.database.Workout
import com.practice.getup.domain.models.Workout
import com.practice.getup.databinding.FragmentMainBinding
import com.practice.getup.presentation.main_menu.view_model.MainMenuViewModel
import com.practice.getup.presentation.main_menu.adapter.WorkoutListAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
import com.practice.getup.database.Workout
import com.practice.getup.domain.storage.AddNewWorkoutUseCase
import com.practice.getup.domain.models.Workout
import com.practice.getup.domain.storage.DeleteAllWorkoutsUseCase
import com.practice.getup.domain.storage.DeleteWorkoutUseCase
import com.practice.getup.domain.storage.GetAllWorkoutsUseCase
import com.practice.getup.domain.storage.GetWorkoutUseCase
import com.practice.getup.domain.storage.UpdateWorkoutUseCase
import kotlinx.coroutines.launch

class MainMenuViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.practice.getup.databinding.WorkoutItemBinding
import com.practice.getup.models.Stage
import com.practice.getup.presentation.timer.models.Stage


class WorkoutDiffCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.practice.getup.models
package com.practice.getup.presentation.timer.models

import com.practice.getup.utils.UiText
import com.practice.getup.presentation.timer.utils.UiText

data class Stage(
val id: String,
Expand Down
Loading

0 comments on commit 91af70d

Please sign in to comment.