ariane/app/src/main/java/oppen/tva/io/history/Tab.kt

38 lines
698 B
Kotlin
Raw Normal View History

2020-08-15 14:52:27 +00:00
package oppen.tva.io.history
import java.net.URI
class Tab(val index: Int) {
val history = mutableListOf<URI>()
fun add(uri: URI){
history.add(uri)
}
fun add(address: String){
history.add(URI.create(address))
}
2020-08-15 20:20:15 +00:00
fun getPrevious(): URI? {
return when {
history.size > 1 -> {
history[history.size-2]
}
else -> {
null
}
}
}
fun popHistory(){
history.dropLast(1)
}
2020-08-15 14:52:27 +00:00
companion object{
fun new(index: Int, address: String): Tab {
val tab = Tab(index)
tab.add(address)
return tab
}
}
}