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

Error in generated code on Parcelable with generics #16

Open
fabioCollini opened this issue Sep 25, 2015 · 3 comments
Open

Error in generated code on Parcelable with generics #16

fabioCollini opened this issue Sep 25, 2015 · 3 comments
Labels
Milestone

Comments

@fabioCollini
Copy link

Using ParcelablePlease on a class with a Parcelable field with a generic parameter there is an error in generated code. For example using ObservableParcelable class of data binding framework:

ObservableParcelable<App> app = new ObservableParcelable<>();

the generated code has a compilation error:

target.app = parcel.readParcelable(android.databinding.ObservableParcelable<App>.class.getClassLoader());

It can be fixed easily using a custom bagger:

public class ObservableParcelableBagger implements ParcelBagger<ObservableParcelable> {
    @Override public void write(ObservableParcelable value, Parcel out, int flags) {
        out.writeParcelable(value, flags);
    }

    @Override public ObservableParcelable read(Parcel in) {
        return in.readParcelable(ObservableParcelable.class.getClassLoader());
    }
}

Thanks for this great framework!

@sockeqwe
Copy link
Owner

I see ...
The compilation error is the generic type <App> in ObservableParcelable<App>.class, right?

@sockeqwe sockeqwe added the bug label Sep 25, 2015
@sockeqwe sockeqwe added this to the next milestone Sep 25, 2015
@fabioCollini
Copy link
Author

Yes, to fix it you just need to remove the generic parameter

@sockeqwe
Copy link
Owner

Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants