You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Add information about @AfterViews call order #1157
@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?
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.
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.
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.
Activity
WonderCsabo commentedon Sep 22, 2014
@dodgex as you suggested the doc update, if you have time, can you add the things you proposed?
dodgex commentedon Sep 22, 2014
Ha. I knew you hate me!
I'll see what i can do. :)
dodgex commentedon Sep 23, 2014
@WonderCsabo @yDelouis can one of you confirm that each
@AfterViewsmethod could be called multiple times if for some reason the views change, or am i taking this wrong?dodgex commentedon Sep 23, 2014
Here is a draft of the note that would go on each of the
@AfterXXXwiki pages. The last link will point to a new page where the calling order is explained.Warning
dodgex commentedon Sep 23, 2014
to be more precise with my question about
@AfterViewswhat situations could trigger the call of this methods?dodgex commentedon Sep 23, 2014
another question. :D
in my PR for @AfterExtras i mentioned that
onNewIntent(Intent intent)has to be overridden to set the new intent viasetIntent()so that the injection would get the new data. i just wonder if this should be mentioned somewhere or if we shoud overrideonNewIntent(Intent intent)in the generated class.WonderCsabo commentedon Sep 23, 2014
Indeed. In case of
@EActivity, they are always get called if thesetContentView()method is called. In case of other components, they are only called at initialization.I do not think so, we never write down the implementation of annotations, the client can read that easily in the generated class.
This is a good question. I cannot decide. @yDelouis ?
Great. Thanks for your precise work on this.
yDelouis commentedon Sep 23, 2014
I think we could override
onNewIntentif we callsuper.onNewIntent.WonderCsabo commentedon Sep 23, 2014
BTW
setIntent()callsonNewIntent()or not in plain Android code?yDelouis commentedon Sep 23, 2014
No. It's a common thing to call
setIntent()inonNewIntent(). (See NFC examples).WonderCsabo commentedon Sep 23, 2014
OK, i think i also did that once, but that was a long time ago. Thanks for the clarification.
dodgex commentedon Sep 23, 2014
should we do the override for all activities or only if
@AfterExtrasis used? if i know that, i'll prepare a PR for that.WonderCsabo commentedon Sep 23, 2014
I think only with @AfterExtras.
dodgex commentedon Sep 23, 2014
okay. i'll try to get the PR up this evening together with the updated wiki.
dodgex commentedon Sep 23, 2014
It's not super awesome but I think it is ok. Someone should definitely carefully re-read my changes.
https://github.com/dodgex/androidannotations/wiki/%40AfterXXX-call-order
https://github.com/dodgex/androidannotations/wiki/Extras#warning
https://github.com/dodgex/androidannotations/wiki/Enhance-custom-classes#warning
https://github.com/dodgex/androidannotations/wiki/Injecting-Views#warning
PR for onNewIntent is next. :)
WonderCsabo commentedon Sep 23, 2014
Thanks very much! I only rebased your commits to correct a few typos and convert line endings to LF.
dodgex commentedon Sep 23, 2014
damn. forgot to recheck the line endings. sorry! :(
WonderCsabo commentedon Sep 23, 2014
No problem, do not worry.