Skip to content

Instantly share code, notes, and snippets.

@shem8
Created January 4, 2016 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shem8/9f055499562e67b7f67a to your computer and use it in GitHub Desktop.
Save shem8/9f055499562e67b7f67a to your computer and use it in GitHub Desktop.
fun AppCompatActivity.navigate(frag: Fragment) {
val fragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(content.id, frag);
fragmentTransaction.commit();
}
fun Fragment.userError(msg: String?) {
Snackbar.make(view, msg, Snackbar.LENGTH_LONG).show()
}
fun SharedPreferences.edit(func:SharedPreferences.Editor.(): Unit) {
val editor = edit()
editor.func()
editor.apply()
}
fun SharedPreferences.Editor.set(pair: Pair<String, String>) = putString(pair.first, pair.second)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment