AquaStream/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt

22 lines
703 B
Kotlin
Raw Normal View History

2021-06-15 16:07:20 +00:00
package com.lagradost.cloudstream3.utils
import android.content.Context
import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.setKey
const val VIDEO_POS_DUR = "video_pos_dur"
data class PosDur(val position: Long, val duration: Long)
object DataStoreHelper {
var currentAccount: String = "0" //TODO ACCOUNT IMPLEMENTATION
fun Context.saveViewPos(id: Int?, pos: Long, dur: Long) {
if(id == null) return
setKey("$currentAccount/$VIDEO_POS_DUR", id.toString(), PosDur(pos, dur))
}
fun Context.getViewPos(id: Int): PosDur? {
return getKey<PosDur>("$currentAccount/$VIDEO_POS_DUR", id.toString(), null)
}
}