New cache system

Refactoring
Separation into libraries
This commit is contained in:
2021-03-17 19:47:53 +03:00
parent 2004cb7c5e
commit 84d812a6d6
198 changed files with 4892 additions and 3477 deletions
@@ -0,0 +1,41 @@
package com.meloda.fast
import android.text.TextUtils
import com.meloda.fast.common.AppGlobal
object UserConfig {
private const val TOKEN = "token"
private const val USER_ID = "user_id"
const val API_ID = "6964679"
var token = ""
var userId = 0
fun save() {
AppGlobal.preferences.edit()
.putString(TOKEN, token)
.putInt(USER_ID, userId)
.apply()
}
fun restore() {
token = AppGlobal.preferences.getString(TOKEN, "") ?: ""
userId = AppGlobal.preferences.getInt(USER_ID, -1)
}
fun clear() {
token = ""
userId = -1
AppGlobal.preferences.edit()
.remove(TOKEN)
.remove(USER_ID)
.apply()
}
fun isLoggedIn(): Boolean {
return userId > 0 && !TextUtils.isEmpty(token)
}
}