adds rest list receiver, adds local code storage
- 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
This commit is contained in:
24
app/src/main/java/com/example/bump/LocalData.kt
Normal file
24
app/src/main/java/com/example/bump/LocalData.kt
Normal file
@ -0,0 +1,24 @@
|
||||
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<>
|
||||
}
|
Reference in New Issue
Block a user