Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var ArrayList of Parcelable problem #27

Open
btwarog opened this issue Mar 17, 2018 · 2 comments
Open

var ArrayList of Parcelable problem #27

btwarog opened this issue Mar 17, 2018 · 2 comments

Comments

@btwarog
Copy link

btwarog commented Mar 17, 2018

Library version 1.11-beta

There is an issue if you would try to pass an ArrayList with this library, CustomElement has annotation @parcelize and extends Parcelable.

For single element it's correctly generating fill method in x*Starter class for example it would look like:
activity.setCustomElement((CustomElement)savedInstanceState.getParcelable(CUSTOM_ELEMENT_KEY));
But for an ArrayList of this CustomElement it look like:
activity.setCustomElements(savedInstanceState.getParcelableArrayList(CUSTOM_ELEMENTS_KEY));
And Android Studio marks it as error.

@MarcinMoskala
Copy link
Owner

savedInstanceState is a Bundle which has getParcelableArrayList method and this is preferred way to pass list of elements as an argument. It is even tested. Can you give some more specific example?

@btwarog
Copy link
Author

btwarog commented Mar 18, 2018

I've downloaded your sample, tested it and it's not @parcelize annotation problem. To see what I mean just add in StudentParcelableActivity.kt the following line.

@get:Arg var students: ArrayList<StudentParcelable> by argExtra()

Your library work correctly in Kotlin for:
@get:Arg val students: ArrayList<StudentParcelable> by argExtra()

but it's not working for:
@get:Arg var students: ArrayList<StudentParcelable> by argExtra()

It's the problem of var in case of ArrayList with elements that extends Parcelable.

@btwarog btwarog changed the title KAE Parcelize annotation var ArrayList of Parcelable problem Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants