1
zhujie
2025-04-15 879ec1ae04b37eb7bf9357903d10acc860d84d5b
app/src/main/java/com/example/firstapp/utils/PreferencesManager.kt
@@ -9,6 +9,8 @@
    private const val KEY_PHONE = "user_phone"
    private const val KEY_FIRST_INSTALL = "first_install"
    private const val LAST_LOGIN_PHONE = "last_login_phone"
    private const val PREF_LAST_CHECK_TIME_PREFIX = "last_check_time_"
    private const val KEY_INVITE = "user_invite"
    private lateinit var preferences: SharedPreferences
@@ -55,4 +57,20 @@
    fun getLastLoginPhone(): String {
        return preferences.getString(LAST_LOGIN_PHONE, "") ?: ""
    }
    fun getLastCheckTime(categoryId: Int): Long {
        return preferences.getLong(PREF_LAST_CHECK_TIME_PREFIX + categoryId, 0)
    }
    fun setLastCheckTime(categoryId: Int, time: Long) {
        preferences.edit().putLong(PREF_LAST_CHECK_TIME_PREFIX + categoryId, time).apply()
    }
    fun getInviteCode(): String {
        return preferences.getString(KEY_INVITE, "") ?: ""
    }
    fun setInviteCode(invite: String) {
        preferences.edit().putString(KEY_INVITE, invite).apply()
    }