Repository navigation
Add information about @AfterViews call order #1157
Description
Activity
@dodgex as you suggested the doc update, if you have time, can you add the things you proposed?
Ha. I knew you hate me!
I'll see what i can do. :)
@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?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
If the parent and child classes have
@AfterViews,@AfterInjector@AfterExtrasannotated 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,-Injector-Extrasannotated methods, there is no guaranteed order for calling each of the methods with the same@AfterXXXannotation (see issue #810).Details about when the methods with one of those annotaions where called you can find here.
to be more precise with my question about
@AfterViewswhat situations could trigger the call of this methods?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.@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent); }
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 thesetContentView()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.
I think we could override
onNewIntentif we callsuper.onNewIntent.BTW
setIntent()callsonNewIntent()or not in plain Android code?No. It's a common thing to call
setIntent()inonNewIntent(). (See NFC examples).OK, i think i also did that once, but that was a long time ago. Thanks for the clarification.
should we do the override for all activities or only if
@AfterExtrasis used? if i know that, i'll prepare a PR for that.I think only with @AfterExtras.
okay. i'll try to get the PR up this evening together with the updated wiki.
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#warningPR for onNewIntent is next. :)
Thanks very much! I only rebased your commits to correct a few typos and convert line endings to LF.
damn. forgot to recheck the line endings. sorry! :(
No problem, do not worry.
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.