# android


12/25/2017, 12:12 AM
Context (the Kotlin question comes at the end): I'm building a basic finance tracking app. I have a dialog fragment that is used to enter a transaction for the account. I use a new instance method that takes in the account name and puts it in the bundle and life is good I can reference it in
. Now I want to expand this same dialog fragment to be used for adding or editing a transaction. In my head I see two options: a separate new instance method that takes in the transaction to be edited and I use some flag to determine the state of the dialog. Is there some way to use sealed classes for this, though? I could have like
sealed class TransactionState
with a class for add and edit, but it doesn't look like sealed classes can be parcelable, so idk if what I'm asking is feasible but would love for someone to put my mind at rest about it.


12/25/2017, 7:55 PM
umm a sealed class is still a class so you could implement the parceable interface. it would be alot of boilerplate tho.. You could also just resort back to enums since they are serializble ,or even intDef


12/26/2017, 1:50 AM
I've found the "sub" classes (idk what they're called?) can be parcelable but the sealed class itself can't be. Likely resorting back to the standard way to do it.
Actually, I just ended up doing my switch based on whether or not "existingTransaction" existing in the arguments bundle. Otherwise I went the other route.


12/28/2017, 8:49 PM
Why not regular data classes with a
..? Each one is Parcelable, the only thing gained by sealed classes is exhaustability...
🤔 1


12/28/2017, 8:55 PM
I didn't think about it that way... It's similar to what I already did but might look a little cleaner. Thanks for the suggestion.