#40 timer info class and subclasses, used for display of a timer
This commit is contained in:
parent
66e68493e4
commit
0c183b9cc7
20 changed files with 210 additions and 27 deletions
|
@ -0,0 +1,4 @@
|
|||
package be.ugent.sel.studeez.domain
|
||||
|
||||
interface ConfigurationService {
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
Copyright 2022 Google LLC
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package be.ugent.sel.studeez.domain
|
||||
|
||||
import com.google.firebase.perf.ktx.trace
|
||||
import com.google.firebase.perf.metrics.Trace
|
||||
|
||||
/**
|
||||
* Trace a block with Firebase performance.
|
||||
*
|
||||
* Supports both suspend and regular methods.
|
||||
*/
|
||||
inline fun <T> trace(name: String, block: Trace.() -> T): T = Trace.create(name).trace(block)
|
|
@ -0,0 +1,4 @@
|
|||
package be.ugent.sel.studeez.domain
|
||||
|
||||
interface TimerDAO {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package be.ugent.sel.studeez.domain.implementation
|
||||
|
||||
class FirebaseConfigurationService {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package be.ugent.sel.studeez.domain.implementation
|
||||
|
||||
class FirebaseTimerDAO {
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package be.ugent.sel.studeez.domain.implementation
|
||||
|
||||
import be.ugent.sel.studeez.data.local.models.timer_info.*
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
|
||||
class JsonToTimerConverter {
|
||||
|
||||
private val timerInfoMap: Map<String, TimerFactory> = mapOf(
|
||||
"endless" to TimerFactory { EndlessTimerInfo(it.name, it.description) },
|
||||
"custom" to TimerFactory { CustomTimerInfo(it.name, it.description, it.studyTime) },
|
||||
"break" to TimerFactory { PomodoroTimerInfo(
|
||||
it.name,
|
||||
it.description,
|
||||
it.studyTime,
|
||||
it.breakTime,
|
||||
it.repeats
|
||||
) }
|
||||
)
|
||||
|
||||
private fun getTimer(timerJson: TimerJson): TimerInfo{
|
||||
return timerInfoMap.getValue(timerJson.type).makeTimer(timerJson)
|
||||
}
|
||||
|
||||
fun convertToTimerInfoList(a: List<TimerJson>): List<TimerInfo> {
|
||||
return a.map(this::getTimer)
|
||||
}
|
||||
|
||||
fun jsonToTimerJsonList(json: String): List<TimerJson> {
|
||||
val type = object : TypeToken<List<TimerJson>>() {}.type
|
||||
return Gson().fromJson(json, type)
|
||||
}
|
||||
}
|
Reference in a new issue