merge dev
This commit is contained in:
commit
94336348c5
24 changed files with 377 additions and 166 deletions
|
@ -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
|
||||
}
|
|
@ -5,6 +5,7 @@ class FunctionalCustomTimer(studyTime: Int) : FunctionalTimer(studyTime) {
|
|||
override fun tick() {
|
||||
if (!hasEnded()) {
|
||||
time.minOne()
|
||||
totalStudyTime++
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ class FunctionalEndlessTimer : FunctionalTimer(0) {
|
|||
|
||||
override fun tick() {
|
||||
time.plusOne()
|
||||
totalStudyTime++
|
||||
}
|
||||
|
||||
override fun <T> accept(visitor: FunctionalTimerVisitor<T>): T {
|
||||
|
|
|
@ -23,6 +23,10 @@ class FunctionalPomodoroTimer(
|
|||
isInBreak = !isInBreak
|
||||
}
|
||||
time.minOne()
|
||||
|
||||
if (!isInBreak) {
|
||||
totalStudyTime++
|
||||
}
|
||||
}
|
||||
|
||||
override fun hasEnded(): Boolean {
|
||||
|
|
|
@ -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
|
||||
}
|
Reference in a new issue