Files
Matewave/app/src/main/java/cc/skysparkle/matewave/MatewaveApp.kt
T
2026-11-02 15:51:41 +02:00

37 lines
1.3 KiB
Kotlin

package cc.skysparkle.matewave
import android.app.Application
import cc.skysparkle.matewave.data.FriendsStore
import cc.skysparkle.matewave.data.GameSaveStore
import cc.skysparkle.matewave.data.ProfileStore
import cc.skysparkle.matewave.settings.Haptics
import cc.skysparkle.matewave.stats.Stats
/**
* Sets up the stores once per process, before any screen or the background presence service
* runs: the service can be restarted by the system without the activity.
*/
class MatewaveApp : Application() {
override fun onCreate() {
super.onCreate()
ProfileStore.init(this)
FriendsStore.init(this)
Stats.init(this)
GameSaveStore.init(this)
Haptics.init(this)
// Settings files load on a background thread from first use; start them now, so the
// first screen finds them in memory instead of waiting for the disk.
for (name in EARLY_PREFS) getSharedPreferences(name, MODE_PRIVATE)
GameSaveStore.preload()
}
private companion object {
/** Settings the home screen and its view models read while starting. */
val EARLY_PREFS = arrayOf(
"chess_profile_prefs", "chess_friends_prefs", "chess_stats_prefs", "chess_sound_prefs",
"last_game_setup", "presence_settings", "opening_srs"
)
}
}