merge dev

This commit is contained in:
Rune Dyselinck 2023-04-28 15:50:44 +02:00
commit 94336348c5
24 changed files with 377 additions and 166 deletions

View file

@ -0,0 +1,14 @@
package be.ugent.sel.studeez.data
import be.ugent.sel.studeez.data.local.models.SessionReport
import javax.inject.Inject
import javax.inject.Singleton
/**
* Used to communicate the SelectedTimer from the selection screen to the session screen.
* Because this is a singleton-class the view-models of both screens observe the same data.
*/
@Singleton
class SessionReportState @Inject constructor(){
var sessionReport: SessionReport? = null
}

View file

@ -5,6 +5,7 @@ class FunctionalCustomTimer(studyTime: Int) : FunctionalTimer(studyTime) {
override fun tick() {
if (!hasEnded()) {
time.minOne()
totalStudyTime++
}
}

View file

@ -12,6 +12,7 @@ class FunctionalEndlessTimer : FunctionalTimer(0) {
override fun tick() {
time.plusOne()
totalStudyTime++
}
override fun <T> accept(visitor: FunctionalTimerVisitor<T>): T {

View file

@ -23,6 +23,10 @@ class FunctionalPomodoroTimer(
isInBreak = !isInBreak
}
time.minOne()
if (!isInBreak) {
totalStudyTime++
}
}
override fun hasEnded(): Boolean {

View file

@ -1,7 +1,11 @@
package be.ugent.sel.studeez.data.local.models.timer_functional
import be.ugent.sel.studeez.data.local.models.SessionReport
import com.google.firebase.Timestamp
abstract class FunctionalTimer(initialValue: Int) {
val time: Time = Time(initialValue)
var totalStudyTime: Int = 0
fun getHoursMinutesSeconds(): HoursMinutesSeconds {
return time.getAsHMS()
@ -13,5 +17,12 @@ abstract class FunctionalTimer(initialValue: Int) {
abstract fun hasCurrentCountdownEnded(): Boolean
fun getSessionReport(): SessionReport {
return SessionReport(
studyTime = totalStudyTime,
endTime = Timestamp.now()
)
}
abstract fun <T> accept(visitor: FunctionalTimerVisitor<T>): T
}