#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.data.local.models.timer_functional
 | 
			
		||||
 | 
			
		||||
class FunctionalCustomTimer {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_functional
 | 
			
		||||
 | 
			
		||||
class FunctionalEndlessTimer {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_functional
 | 
			
		||||
 | 
			
		||||
class FunctionalPomodoroTimer {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_functional
 | 
			
		||||
 | 
			
		||||
class FunctionalTimer {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_functional
 | 
			
		||||
 | 
			
		||||
data class HoursMinutesSeconds()
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_functional
 | 
			
		||||
 | 
			
		||||
class Time {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,31 @@
 | 
			
		|||
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
 | 
			
		||||
 | 
			
		||||
class BreakTimerInfo(
 | 
			
		||||
    name: String,
 | 
			
		||||
    description: String,
 | 
			
		||||
    private val studyTime: Int,
 | 
			
		||||
    private val breakTime: Int,
 | 
			
		||||
    private val repeats: Int,
 | 
			
		||||
    id: String = ""
 | 
			
		||||
):  TimerInfo(id, name, description) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    override fun getFunctionalTimer(): FunctionalTimer {
 | 
			
		||||
        return FunctionalPomodoroTimer(studyTime, breakTime, repeats)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun asJson() : Map<String, Any> {
 | 
			
		||||
        return mapOf(
 | 
			
		||||
            "type" to "break",
 | 
			
		||||
            "name" to name,
 | 
			
		||||
            "description" to description,
 | 
			
		||||
            "studyTime" to studyTime,
 | 
			
		||||
            "breakTime" to breakTime,
 | 
			
		||||
            "repeats" to repeats,
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_info
 | 
			
		||||
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalCustomTimer
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
 | 
			
		||||
 | 
			
		||||
class CustomTimerInfo(
 | 
			
		||||
    name: String,
 | 
			
		||||
    description: String,
 | 
			
		||||
    private val studyTime: Int,
 | 
			
		||||
    id: String = ""
 | 
			
		||||
):  TimerInfo(id, name, description) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    override fun getFunctionalTimer(): FunctionalTimer {
 | 
			
		||||
        return FunctionalCustomTimer(studyTime)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun asJson() : Map<String, Any> {
 | 
			
		||||
        return mapOf(
 | 
			
		||||
            "type" to "custom",
 | 
			
		||||
            "name" to name,
 | 
			
		||||
            "description" to description,
 | 
			
		||||
            "studyTime" to studyTime,
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,25 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_info
 | 
			
		||||
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalEndlessTimer
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
 | 
			
		||||
 | 
			
		||||
class EndlessTimerInfo(
 | 
			
		||||
    name: String,
 | 
			
		||||
    description: String,
 | 
			
		||||
    id: String = ""
 | 
			
		||||
):  TimerInfo(id, name, description) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    override fun getFunctionalTimer(): FunctionalTimer {
 | 
			
		||||
        return FunctionalEndlessTimer()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun asJson() : Map<String, Any> {
 | 
			
		||||
        return mapOf(
 | 
			
		||||
            "type" to "endless",
 | 
			
		||||
            "name" to name,
 | 
			
		||||
            "description" to description
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_info
 | 
			
		||||
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Deze klasse stelt de de info van een timer weer. Elke timer heeft een id, naam en descriptie
 | 
			
		||||
 */
 | 
			
		||||
abstract class TimerInfo(
 | 
			
		||||
    val id: String,
 | 
			
		||||
    val name: String,
 | 
			
		||||
    val description: String
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Geef de functionele timer terug die kan gebruikt worden tijden een sessie.
 | 
			
		||||
     */
 | 
			
		||||
    abstract fun getFunctionalTimer(): FunctionalTimer
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Geef deze timer weer als json. Wordt gebruikt om terug op te slaan in de databank.
 | 
			
		||||
     * TODO implementaties hebben nog hardgecodeerde strings.
 | 
			
		||||
     */
 | 
			
		||||
    abstract fun asJson(): Map<String, Any>
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_info
 | 
			
		||||
 | 
			
		||||
import com.google.firebase.firestore.DocumentId
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Timers uit de databank (remote config en firestore) worden als eerste stap omgezet naar dit type.
 | 
			
		||||
 */
 | 
			
		||||
data class TimerJson(
 | 
			
		||||
    val type: String = "",
 | 
			
		||||
    val name: String = "",
 | 
			
		||||
    val description: String = "",
 | 
			
		||||
    val studyTime: Int = 0,
 | 
			
		||||
    val breakTime: Int = 0,
 | 
			
		||||
    val repeats: Int = 0,
 | 
			
		||||
    @DocumentId val id: String = ""
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
package be.ugent.sel.studeez.data.local.models.timer_info
 | 
			
		||||
 | 
			
		||||
enum class TimerType {
 | 
			
		||||
    BREAK,
 | 
			
		||||
    ENDLESS,
 | 
			
		||||
    CUSTOM
 | 
			
		||||
}
 | 
			
		||||
		Reference in a new issue