api refactored and cleaned

This commit is contained in:
2021-08-31 16:20:09 +03:00
parent c3208fd95e
commit b09ae2049c
40 changed files with 129 additions and 2107 deletions
@@ -0,0 +1,33 @@
package com.meloda.fast.api
import com.meloda.fast.common.AppGlobal
object UserConfig {
private const val TOKEN = "token"
private const val USER_ID = "user_id"
const val FAST_APP_ID = "6964679"
var userId: Int = -1
get() = AppGlobal.preferences.getInt(USER_ID, -1)
set(value) {
field = value
AppGlobal.preferences.edit().putInt(USER_ID, value).apply()
}
var accessToken: String = ""
get() = AppGlobal.preferences.getString(TOKEN, "") ?: ""
set(value) {
field = value
AppGlobal.preferences.edit().putString(TOKEN, value).apply()
}
fun clear() {
accessToken = ""
userId = -1
}
fun isLoggedIn() = userId > 0 && accessToken.isNotBlank()
}