-
Notifications
You must be signed in to change notification settings - Fork 86
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
21 changed files
with
945 additions
and
42 deletions.
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
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
6 changes: 6 additions & 0 deletions
6
...in/java/com/example/util/simpletimetracker/core/dialog/RecordQuickActionDialogListener.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,6 @@ | ||
package com.example.util.simpletimetracker.core.dialog | ||
|
||
interface RecordQuickActionDialogListener { | ||
|
||
fun onUpdate() | ||
} |
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
38 changes: 38 additions & 0 deletions
38
...java/com/example/util/simpletimetracker/domain/interactor/RecordActionContinueMediator.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,38 @@ | ||
package com.example.util.simpletimetracker.domain.interactor | ||
|
||
import com.example.util.simpletimetracker.domain.extension.orZero | ||
import javax.inject.Inject | ||
|
||
class RecordActionContinueMediator @Inject constructor( | ||
private val runningRecordInteractor: RunningRecordInteractor, | ||
private val addRunningRecordMediator: AddRunningRecordMediator, | ||
private val removeRunningRecordMediator: RemoveRunningRecordMediator, | ||
private val recordInteractor: RecordInteractor, | ||
private val removeRecordMediator: RemoveRecordMediator, | ||
) { | ||
|
||
suspend fun execute( | ||
recordId: Long?, | ||
typeId: Long, | ||
timeStarted: Long, | ||
comment: String, | ||
tagIds: List<Long>, | ||
) { | ||
// Remove current record if exist. | ||
recordId?.let { | ||
val oldTypeId = recordInteractor.get(it)?.typeId.orZero() | ||
removeRecordMediator.remove(it, oldTypeId) | ||
} | ||
// Stop same type running record if exist (only one of the same type can run at once). | ||
// Widgets will update on adding. | ||
runningRecordInteractor.get(typeId) | ||
?.let { removeRunningRecordMediator.removeWithRecordAdd(it, updateWidgets = false) } | ||
// Add new running record. | ||
addRunningRecordMediator.startTimer( | ||
typeId = typeId, | ||
timeStarted = timeStarted, | ||
comment = comment, | ||
tagIds = tagIds, | ||
) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ava/com/example/util/simpletimetracker/domain/interactor/RecordActionDuplicateMediator.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.example.util.simpletimetracker.domain.interactor | ||
|
||
import com.example.util.simpletimetracker.domain.model.Record | ||
import javax.inject.Inject | ||
|
||
class RecordActionDuplicateMediator @Inject constructor( | ||
private val addRecordMediator: AddRecordMediator, | ||
) { | ||
|
||
suspend fun execute( | ||
typeId: Long, | ||
timeStarted: Long, | ||
timeEnded: Long, | ||
comment: String, | ||
tagIds: List<Long>, | ||
) { | ||
Record( | ||
typeId = typeId, | ||
timeStarted = timeStarted, | ||
timeEnded = timeEnded, | ||
comment = comment, | ||
tagIds = tagIds, | ||
).let { | ||
addRecordMediator.add(it) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...in/java/com/example/util/simpletimetracker/domain/interactor/RecordActionMergeMediator.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,23 @@ | ||
package com.example.util.simpletimetracker.domain.interactor | ||
|
||
import com.example.util.simpletimetracker.domain.model.Record | ||
import javax.inject.Inject | ||
|
||
class RecordActionMergeMediator @Inject constructor( | ||
private val addRecordMediator: AddRecordMediator, | ||
) { | ||
|
||
suspend fun execute( | ||
prevRecord: Record?, | ||
newTimeEnded: Long, | ||
onMergeComplete: () -> Unit, | ||
) { | ||
// If merge would be available but only for untracked - add removal of current record | ||
prevRecord?.copy( | ||
timeEnded = newTimeEnded, | ||
)?.let { | ||
addRecordMediator.add(it) | ||
onMergeComplete() | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...n/java/com/example/util/simpletimetracker/domain/interactor/RecordActionRepeatMediator.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.example.util.simpletimetracker.domain.interactor | ||
|
||
import javax.inject.Inject | ||
|
||
class RecordActionRepeatMediator @Inject constructor( | ||
private val runningRecordInteractor: RunningRecordInteractor, | ||
private val addRunningRecordMediator: AddRunningRecordMediator, | ||
private val removeRunningRecordMediator: RemoveRunningRecordMediator, | ||
) { | ||
|
||
suspend fun execute( | ||
typeId: Long, | ||
comment: String, | ||
tagIds: List<Long>, | ||
) { | ||
// Stop same type running record if exist (only one of the same type can run at once). | ||
// Widgets will update on adding. | ||
runningRecordInteractor.get(typeId) | ||
?.let { removeRunningRecordMediator.removeWithRecordAdd(it, updateWidgets = false) } | ||
// Add new running record. | ||
addRunningRecordMediator.startTimer( | ||
typeId = typeId, | ||
comment = comment, | ||
tagIds = tagIds, | ||
) | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...til/simpletimetracker/feature_dialogs/recordQuickActions/model/RecordQuickActionsState.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.example.util.simpletimetracker.feature_dialogs.recordQuickActions.model | ||
|
||
data class RecordQuickActionsState( | ||
val buttons: List<Button>, | ||
) { | ||
|
||
sealed interface Button { | ||
val wrapBefore: Boolean | ||
|
||
data class Statistics( | ||
override val wrapBefore: Boolean, | ||
) : Button | ||
|
||
data class Delete( | ||
override val wrapBefore: Boolean, | ||
) : Button | ||
|
||
data class Continue( | ||
override val wrapBefore: Boolean, | ||
) : Button | ||
|
||
data class Repeat( | ||
override val wrapBefore: Boolean, | ||
) : Button | ||
|
||
data class Duplicate( | ||
override val wrapBefore: Boolean, | ||
) : Button | ||
|
||
data class Merge( | ||
override val wrapBefore: Boolean, | ||
) : Button | ||
} | ||
} |
Oops, something went wrong.