This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Abstract Foodium database. | |
| * It provides DAO [DEtailsDap] by using method [getDEtailsDAO]. | |
| */ | |
| @Database( | |
| entities = [UserDetails::class], | |
| version = 1, | |
| exportSchema = false | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PreferenceHelper(private val mContext: Context = App.applicationContext()) { | |
| fun putInt(key: String?, value: Int): PreferenceHelper { | |
| val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext) | |
| val edit = preferences.edit() | |
| edit.putInt(key, value) | |
| edit.apply() | |
| return this | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object DataPersistenceManager { | |
| private const val KEY_TOKEN = "dpm_token" | |
| private var token: AccessToken? = null | |
| fun getTokenDetails(c: Context): AccessToken? { | |
| if(token == null) loadToken(c) | |
| return token | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object NetworkUtils { | |
| private val networkLiveData: MutableLiveData<Boolean> = MutableLiveData() | |
| /** | |
| * Returns instance of [LiveData] which can be observed for network changes. | |
| */ | |
| fun getNetworkLiveData(context: Context): LiveData<Boolean> { | |
| val connectivityManager = | |
| context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager |