commit
ee7914d0c9
23 changed files with 250 additions and 18 deletions
|
@ -0,0 +1,4 @@
|
|||
package be.ugent.sel.studeez.data
|
||||
|
||||
class EditTimerState {
|
||||
}
|
|
@ -1,4 +1,15 @@
|
|||
package be.ugent.sel.studeez.data.local.models.timer_functional
|
||||
|
||||
data class HoursMinutesSeconds(val hours: String, val minutes: String, val seconds: String
|
||||
)
|
||||
data class HoursMinutesSeconds(val hours: Int, val minutes: Int, val seconds: Int) {
|
||||
|
||||
fun getTotalSeconds(): Int {
|
||||
return hours * 60 * 60 + minutes * 60 + seconds
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
val hoursString = hours.toString().padStart(2, '0')
|
||||
val minutesString = minutes.toString().padStart(2, '0')
|
||||
val secondsString = seconds.toString().padStart(2, '0')
|
||||
return "$hoursString : $minutesString : $secondsString"
|
||||
}
|
||||
}
|
|
@ -17,11 +17,7 @@ class Time(initialTime: Int) {
|
|||
val minutes: Int = (time / (60)) % 60
|
||||
val seconds: Int = time % 60
|
||||
|
||||
return HoursMinutesSeconds(
|
||||
hours.toString().padStart(2, '0'),
|
||||
minutes.toString().padStart(2, '0'),
|
||||
seconds.toString().padStart(2, '0')
|
||||
)
|
||||
return HoursMinutesSeconds(hours, minutes, seconds)
|
||||
}
|
||||
|
||||
}
|
|
@ -6,11 +6,10 @@ import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
|||
class CustomTimerInfo(
|
||||
name: String,
|
||||
description: String,
|
||||
private val studyTime: Int,
|
||||
var studyTime: Int,
|
||||
id: String = ""
|
||||
): TimerInfo(id, name, description) {
|
||||
|
||||
|
||||
override fun getFunctionalTimer(): FunctionalTimer {
|
||||
return FunctionalCustomTimer(studyTime)
|
||||
}
|
||||
|
@ -24,4 +23,8 @@ class CustomTimerInfo(
|
|||
)
|
||||
}
|
||||
|
||||
override fun <T> accept(visitor: TimerInfoVisitor<T>): T {
|
||||
return visitor.visitCustomTimerInfo(this)
|
||||
}
|
||||
|
||||
}
|
|
@ -22,4 +22,8 @@ class EndlessTimerInfo(
|
|||
)
|
||||
}
|
||||
|
||||
override fun <T> accept(visitor: TimerInfoVisitor<T>): T {
|
||||
return visitor.visitEndlessTimerInfo(this)
|
||||
}
|
||||
|
||||
}
|
|
@ -2,13 +2,14 @@ package be.ugent.sel.studeez.data.local.models.timer_info
|
|||
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimerVisitor
|
||||
|
||||
class PomodoroTimerInfo(
|
||||
name: String,
|
||||
description: String,
|
||||
private val studyTime: Int,
|
||||
private val breakTime: Int,
|
||||
private val repeats: Int,
|
||||
val studyTime: Int,
|
||||
val breakTime: Int,
|
||||
val repeats: Int,
|
||||
id: String = ""
|
||||
): TimerInfo(id, name, description) {
|
||||
|
||||
|
@ -28,4 +29,8 @@ class PomodoroTimerInfo(
|
|||
)
|
||||
}
|
||||
|
||||
override fun <T> accept(visitor: TimerInfoVisitor<T>): T {
|
||||
return visitor.visitBreakTimerInfo(this)
|
||||
}
|
||||
|
||||
}
|
|
@ -7,8 +7,8 @@ import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
|||
*/
|
||||
abstract class TimerInfo(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val description: String
|
||||
var name: String,
|
||||
var description: String
|
||||
) {
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,7 @@ abstract class TimerInfo(
|
|||
* TODO implementaties hebben nog hardgecodeerde strings.
|
||||
*/
|
||||
abstract fun asJson(): Map<String, Any>
|
||||
abstract fun <T> accept(visitor: TimerInfoVisitor<T>): T
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package be.ugent.sel.studeez.data.local.models.timer_info
|
||||
|
||||
interface TimerInfoVisitor<T> {
|
||||
|
||||
fun visitCustomTimerInfo(customTimerInfo: CustomTimerInfo): T
|
||||
|
||||
fun visitEndlessTimerInfo(endlessTimerInfo: EndlessTimerInfo): T
|
||||
|
||||
fun visitBreakTimerInfo(pomodoroTimerInfo: PomodoroTimerInfo): T
|
||||
|
||||
}
|
Reference in a new issue