Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

@Parcelable  #301

Closed
Closed

Description

@eric-taix

Implement the Parcelable interface is a waste of time and it's always the same code :
for each attributes to be parceled
get the value
write it (according to its type)
end for

Same kind of code when reading a parcelable

And some glue !

A @parcelable annotation would be really appreciated and will save a lot of time to all of us

Activity

  1. eric-taix commented on Oct 6, 2013

    @eric-taix
    Author

    Sorry everyone, I was working on another project so I had no time to work on AA...
    Currently I'm writing some functional tests to verify if everything is OK before sending a pull request.

    If you want to test the @Parcelable / @NonParcelable annotation right now, just fork my repository (eric-taix/androidannotations) and use branch 301_parcelable.

  2. WonderCsabo commented on Jan 9, 2014

    @WonderCsabo
    Member

    I just found a library which does exactly the same thing: https://github.com/johncarl81/parceler . I think it should be considered both implementation and functionality. :)

  3. johncarl81 commented on Apr 12, 2014

    @johncarl81
    Contributor

    Is there interest in integrating Parceler directly?

  4. WonderCsabo commented on Apr 18, 2014

    @WonderCsabo
    Member

    I think that would be nice. @DayS what is your opinion?

  5. DayS commented on Apr 22, 2014

    @DayS
    Contributor

    I think it's a wonderful idea :)

  6. WonderCsabo commented on Jun 1, 2014

    @WonderCsabo
    Member

    Since Parceler cannot be integrated because it causes AA to depend on the whole transfuse framework, i started working in our implementation based on @eric-taix's work.

    It seems the current implementation just generates the class, and does not take any EComponentHolder into account. I think this is not good, because one could want an enhanced component to be Parcelable (for example Views are pretty general), it won't work. @DayS what do you think? Can we restrict the usage of this annotation to enhanced components? Or is there any way to use an annotation handler outside of an enhanced component?

  7. yDelouis commented on Jun 2, 2014

    @yDelouis
    Contributor

    I think it lacks an annotation to enhance real POJO (object which are not aware of the Context).
    I'd like to have @EBean for this kind of object and @EHelper instead of our current @EBean. But we can't break our API.

    And what about annotating only the field with @Parceled for field we want to be put in the parcel ?
    It seems more easy to validate and to process for AA, and to understand for a developer than putting only one annotation for all fields. Then, it's more in the spirit of AA to have an annotation consider only what it's annotating (field, class or method).

  8. WonderCsabo commented on Jun 2, 2014

    @WonderCsabo
    Member

    Actually the current implementation only works with POJOs.

    Yeah, it would be more convenient to develop if we would annotate the fields, but it results in more annotations in the code. But how can we create a processor which works on POJOs and enhanced components, too? This would be the new @EBean what you are talking about?

  9. yDelouis commented on Jun 2, 2014

    @yDelouis
    Contributor

    This would be the new @ebean what you are talking about?

    Yes, we have to create a holder for enhanced POJOs, extending BaseGeneratedClassHolder. So we need an annotation (starting by E) to declare that the class will be enhanced.
    And then, we declare that the class is Parcelable by adding @Parcelable on the class or adding @Parceled on the fields.

    Yeah, it would be more convenient to develop if we would annotate the fields, but it results in more annotations in the code.

    I agree, but it also easier to understand for a AA user. Then, private fields won't be parceled (the generated class won't be able to access them). Non parcelable fields either. How do you warn the user about this behaviour ? With an annotation on each field, you can return an error if the field is private or non parcelable.

  10. WonderCsabo commented on Jun 2, 2014

    @WonderCsabo
    Member

    OK. Unfortunately i do not know AA infrastructure enough to do this change, nor i want to create that, this is too important. Can you implement that sometime?

  11. DayS commented on Jun 8, 2014

    @DayS
    Contributor

    I'd like to have @ebean for this kind of object and @ehelper instead of our current @ebean. But we can't break our API.

    Why not but I'm not sure it worth adding feature. Parcelable could be an exception so if you have any other use case where another root annotation is needed, I'm listening :)

    About parcelable, we'll need three annotations :

    • @EParcelable to enhanced a class and generate parcelable behavior
    • @Parceled to mark a field to be handle by generated parcelable
    • @Parcelable to inject the parcelable object in another enhanced class
  12. yDelouis commented on Jun 16, 2014

    @yDelouis
    Contributor

    The thing is that as Parcelable is an interface, it shouldn't be responsible for generating the extending class. Indeed, imagine that, in the future, we have another interface like Parcelable that we want to take into account, let's say Databasable. We don't want them to be dependent of each other. So, this way, both will generate an extending class. And we won't be able to use both annotations on the same class.

    That's why I think that a generating annotation should represent an "extending" relation, not an interface.
    Like EActivity means that the class extends Activity, EService means that the class extends Service, EBean means that the class extends Object and has a Context. And I think, it lacks an annotation for a class extending Object without any Context. That's why I proposed to rename EBean to EHelper and add a new EBean.

  13. WonderCsabo commented on Jun 16, 2014

    @WonderCsabo
    Member

    @yDelouis Are you sure we have to break our API? Can't we leave @EBean as is and add a new name for the Context-less enhanced class?

  14. yDelouis commented on Jun 16, 2014

    @yDelouis
    Contributor

    Of course we can leave @EBean as it is.
    But I think this name doesn't fit well with what it is.
    Any idea for the new enhanced class ?

  15. WonderCsabo commented on Jun 16, 2014

    @WonderCsabo
    Member

    Maybe you are right. If we have an annotation for beans (POJOs), we should not call the annotation for not beans @EBean. But i think @DayS should make a decision here.

    BTW i think we should focus are resources. First the current PRs should be finished and merged, i see you already started the plugin-system, etc.

  16. DayS commented on Jun 29, 2014

    @DayS
    Contributor

    We can't change the behavior of EBean. It'll be a pain in the ass for every developer using AA as they'll not understand why they don't have context anymore. There are only two options :

    • find another annotation name for enhanced pojo.
    • deprecate EBean, release the 3.1. reintroduce EBean with new behavior and add EHelper then release 3.2.

    But still, I can see all issues about Ebean not having context :)

    Right now, the only names I could think of are : EUtil, EPojo, EObject

  17. yDelouis commented on Oct 6, 2015

    @yDelouis
    Contributor

    Implemented in #1559.

  18. removed this from the Someday milestone on Oct 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions