Skip to content

Instantly share code, notes, and snippets.

@AkshayChordiya
Created March 22, 2017 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkshayChordiya/a737024d4c449d32c2f1018858733883 to your computer and use it in GitHub Desktop.
Save AkshayChordiya/a737024d4c449d32c2f1018858733883 to your computer and use it in GitHub Desktop.
Kotlin Article: TimerUtils.kt
val PREF_TIME_KEY = "Start_time"
fun didTimeStart(context: Context): Boolean {
when {
exists(context, PREF_TIME_KEY) -> return true
else -> return getStartTime(context) != 0L
}
}
fun removeStartTime(context: Context) {
remove(context, PREF_TIME_KEY)
}
fun getStartTime(context: Context): Long {
return getLong(context, PREF_TIME_KEY, 0)
}
fun setStartTime(context: Context, time: Long) {
putLong(context, PREF_TIME_KEY, time)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment