-
-
Save shaon2016/b3b29c9226eb53f1e702dfbde45ec788 to your computer and use it in GitHub Desktop.
This file contains 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 P { | |
private val TAG = P::class.java.simpleName | |
private var prefs: SharedPreferences? = null | |
private var prefsEditor: SharedPreferences.Editor? = null | |
@SuppressLint("CommitPrefEdits") | |
private fun assurePrefNotNull(context: Context) { | |
if (prefs == null) | |
prefs = PreferenceManager.getDefaultSharedPreferences(context) | |
if (prefsEditor == null) { | |
prefsEditor = PreferenceManager | |
.getDefaultSharedPreferences(context).edit() | |
prefsEditor!!.apply() | |
} | |
} | |
fun setShowFirstTimeShowCase(context: Context, set:Boolean) { | |
assurePrefNotNull(context) | |
prefsEditor!!.putBoolean(PREF_SHOW_FIRST_TIME_SHOW_CASE, set) | |
prefsEditor!!.commit() | |
} | |
fun getShowFirstTimeShowCase(ctx: Context): Boolean { | |
assurePrefNotNull(ctx) | |
return prefs!!.getBoolean(PREF_SHOW_FIRST_TIME_SHOW_CASE, false) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment