~/talk

Custom Codecs with KotlinX Serialization

Talkat droidcon Berlin 2025 · 2025-09-24..09-26· [kotlin]
slides:none on file

Built a custom SaveState encoder/decoder on top of KotlinX Serialization that roundtrips serializable objects into a multiplatform SaveState (Android Bundle on JVM, map on other targets), implements CompositeEncoder via AbstractEncoder, and uses platform fast paths for Parcelables and Java Serializable to avoid bundle boxing. It powers a polymorphic nav backstack with rememberSerializable and a convenience rememberNavBackStack, works in practice but requires explicit subclass registration for open polymorphism or an Android-only reflection-based nav key serializer as a tradeoff.

AI-written summary · about

  1. 0:00KotlinX Serialization intro
  2. 1:04Save state needs serialization
  3. 3:09Save state encoder/decoder
  4. 5:17Encoder step by step
  5. 8:02Nested structures in encoder
  6. 9:46Writing values & optimizations
  7. 11:51Decoder for nested structures
  8. 13:13Reading basic types
  9. 14:17Full round trip demo
  10. 16:24Build your own codec?
  11. 17:07Navigation tree serialization
  12. 18:32State with KotlinX Serialization
  13. 21:00Polymorphic serialization
  14. 22:03NavKey for common types
  15. 23:27RememberNavBackStack function
  16. 24:52NavKey serializer (reflection)
  17. 27:20NavBackStackSerializer details
  18. 28:46Sealed classes vs custom serializers
  19. 30:37Future KotlinX improvements
  20. 31:41Custom NavKey serializers
  21. 32:43Save state with ViewModel
  22. 33:27Navigation state flexibility
  23. 33:49Conclusion & try Navigation 3
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.