- rest class now receives a list as well as single messages - adds support for threaded singleton which takes care of continuous checking of the bump server to get the most up-to-date list of messages - adds local data class with tests to get locally saved code in preferences
24 lines
678 B
Kotlin
24 lines
678 B
Kotlin
package com.example.bump
|
|
|
|
import android.content.Context
|
|
import android.content.Context.MODE_PRIVATE
|
|
import android.content.SharedPreferences
|
|
import com.maenle.bump.R
|
|
|
|
class LocalData(context: Context) {
|
|
private val codeKey = context.getString(R.string.code_key)
|
|
private val preferenceKey = context.getString(R.string.preference_file_key)
|
|
|
|
private val preferences: SharedPreferences =
|
|
context.getSharedPreferences(preferenceKey, MODE_PRIVATE)
|
|
|
|
var code: String?
|
|
get() {
|
|
return preferences.getString(codeKey, null)
|
|
}
|
|
set(codeValue) {
|
|
preferences.edit().putString(codeKey, codeValue).apply()
|
|
}
|
|
|
|
// var messages: List<>
|
|
} |