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.

Add information about @AfterViews call order #1157

Description

@WonderCsabo

See details in #810. We cannot guarantee to order of the method calls, but there is a clean workaround for this. This should be added to the wiki.

Activity

  1. WonderCsabo commented on Sep 22, 2014

    @WonderCsabo
    MemberAuthor

    @dodgex as you suggested the doc update, if you have time, can you add the things you proposed?

  2. dodgex commented on Sep 22, 2014

    @dodgex
    Member

    Ha. I knew you hate me!

    I'll see what i can do. :)

  3. dodgex commented on Sep 23, 2014

    @dodgex
    Member

    @WonderCsabo @yDelouis can one of you confirm that each @AfterViews method could be called multiple times if for some reason the views change, or am i taking this wrong?

  4. dodgex commented on Sep 23, 2014

    @dodgex
    Member

    Here is a draft of the note that would go on each of the @AfterXXX wiki pages. The last link will point to a new page where the calling order is explained.


    Warning

    If the parent and child classes have @AfterViews, @AfterInject or @AfterExtras annotated methods with the same name, the generated code will be buggy. See issue #591 for more details.

    Also, while there is a guaranteed order about when we call @AfterViews, -Inject or -Extras annotated methods, there is no guaranteed order for calling each of the methods with the same @AfterXXX annotation (see issue #810).

    Details about when the methods with one of those annotaions where called you can find here.

  5. dodgex commented on Sep 23, 2014

    @dodgex
    Member

    to be more precise with my question about @AfterViews what situations could trigger the call of this methods?

  6. dodgex commented on Sep 23, 2014

    @dodgex
    Member

    another question. :D

    in my PR for @AfterExtras i mentioned that onNewIntent(Intent intent) has to be overridden to set the new intent via setIntent() so that the injection would get the new data. i just wonder if this should be mentioned somewhere or if we shoud override onNewIntent(Intent intent) in the generated class.

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
    }
  7. WonderCsabo commented on Sep 23, 2014

    @WonderCsabo
    MemberAuthor

    can one of you confirm that each @Afterviews method could be called multiple times if for some reason the views change, or am i taking this wrong?

    Indeed. In case of @EActivity, they are always get called if the setContentView() method is called. In case of other components, they are only called at initialization.

    i just wonder if this should be mentioned somewhere

    I do not think so, we never write down the implementation of annotations, the client can read that easily in the generated class.

    if we shoud override onNewIntent(Intent intent) in the generated class

    This is a good question. I cannot decide. @yDelouis ?

    Here is a draft of the note that would go on each of the @afterxxx wiki pages.

    Great. Thanks for your precise work on this.

  8. yDelouis commented on Sep 23, 2014

    @yDelouis
    Contributor

    I think we could override onNewIntent if we call super.onNewIntent.

  9. WonderCsabo commented on Sep 23, 2014

    @WonderCsabo
    MemberAuthor

    BTW setIntent() calls onNewIntent() or not in plain Android code?

  10. yDelouis commented on Sep 23, 2014

    @yDelouis
    Contributor

    No. It's a common thing to call setIntent() in onNewIntent(). (See NFC examples).

  11. WonderCsabo commented on Sep 23, 2014

    @WonderCsabo
    MemberAuthor

    OK, i think i also did that once, but that was a long time ago. Thanks for the clarification.

  12. dodgex commented on Sep 23, 2014

    @dodgex
    Member

    should we do the override for all activities or only if @AfterExtras is used? if i know that, i'll prepare a PR for that.

  13. WonderCsabo commented on Sep 23, 2014

    @WonderCsabo
    MemberAuthor

    I think only with @AfterExtras.

  14. dodgex commented on Sep 23, 2014

    @dodgex
    Member

    okay. i'll try to get the PR up this evening together with the updated wiki.

  15. WonderCsabo commented on Sep 23, 2014

    @WonderCsabo
    MemberAuthor

    Thanks very much! I only rebased your commits to correct a few typos and convert line endings to LF.

  16. dodgex commented on Sep 23, 2014

    @dodgex
    Member

    damn. forgot to recheck the line endings. sorry! :(

  17. WonderCsabo commented on Sep 23, 2014

    @WonderCsabo
    MemberAuthor

    No problem, do not worry.

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