Skip to content

Instantly share code, notes, and snippets.

@k0siara
Created February 12, 2022 18:46
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 k0siara/be1676489ebf8af648ddc93ada218ad4 to your computer and use it in GitHub Desktop.
Save k0siara/be1676489ebf8af648ddc93ada218ad4 to your computer and use it in GitHub Desktop.
class ExampleNavType : NavType<Example>(isNullableAllowed = false) {
override fun get(bundle: Bundle, key: String): Example? {
return bundle.getParcelable(key)
}
override fun parseValue(value: String): Example {
return Gson().fromJson(value, Example::class.java)
}
override fun put(bundle: Bundle, key: String, value: Example) {
bundle.putParcelable(key, value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment