8000 allow method injection #204 by dodgex · Pull Request #1457 · androidannotations/androidannotations · GitHub 8000
[go: up one dir, main page]

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

Conversation

@dodgex
Copy link
Member
@dodgex dodgex commented Jun 7, 2015

this is the WIP branch for method injection. in its initial implementation only for @Bean but planned to be expanded to most (if not all) injection related annotations.

@dodgex
Copy link
Member Author
dodgex commented Jun 7, 2015

related to #204

@WonderCsabo
Copy link
Member

Nice start! Can you please rebase this onto develop?

@dodgex
Copy link
Member Author
dodgex commented Sep 12, 2015

rebased

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo in the method name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo fixed

@yDelouis
Copy link
Contributor

Seems good. However, if you want to extend this to all injection annotation, I think we will need to create a helper in order not to have to duplicate this code structure in all Handlers.

@dodgex
Copy link
Member Author
dodgex commented Sep 20, 2015

i started this as PoC to see what is possible. but yeah, how that we found that it is possible the plan is to extend it to (if possible) all injections

@dodgex
Copy link
Member Author
dodgex commented Sep 20, 2015

@WonderCsabo @yDelouis i updated the PR. i refactored the code into a helper class and added method injection for @SystemService.

feedback is highly appreciated!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields should be private.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should they? in other tests similar fields are default too. thats why i left the visibiliy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. The fields are packapege private because we have to access them from the test class.

I just said it because we want method injections to be able to inject to private fields (at least this is on of the reasons). But we still have to access the fields in the test class, so just forget my comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just realized that there is no consistency at all in the test classes. the BeanInjctedActivity has all fields public

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields should be pp, but it is not a big deal.

@WonderCsabo
Copy link
Member

I am wondering, could it be easier to create a common super AnnotationHandler class instead of the InjectHelper for method injecting annotations?

@WonderCsabo
Copy link
Member

This should be rebased.

@dodgex
Copy link
Member Author
dodgex commented Sep 21, 2015

rebased an adressed some of the comments

@dodgex
Copy link
Member Author
dodgex commented Sep 21, 2015

about the common super class.

first the question is what injections should be supported? e.g. @Pref has CoreBaseAnnotationHandler as parent class but the @Bean and @SystemService have BaseAnnotationHandler

not sure what the purpose of CoreBaseAnnotationHandler beside the fact that has a CoreValidationHelper. if it is ok we could use this as a common base or better extend it for that base.

@dodgex
Copy link
Member Author
dodgex commented Sep 22, 2015

here is a list of annotations that ca be applied to fields. the checked are already supported.

  • @App
  • @Bean
  • @Extra
  • @FragmentArg
  • @FragmentById
  • @FragmentByTag
  • @HttpsClient
  • @InjectMenu
  • @OptionsMenuItem
  • @PreferenceByKey
  • @AnimationRes
  • @BooleanRes
  • @ColorRes
  • @ColorStateListRes
  • @DimensionPixelOffsetRes
  • @DimensionPixelSizeRes
  • @DimensionRes
  • @DrawableRes
  • @HtmlRes
  • @IntArrayRes
  • @IntegerRes
  • @LayoutRes
  • @MovieRes
  • @StringArrayRes
  • @StringRes
  • @TextArrayRes
  • @TextRes
  • @RootContext
  • @Pref
  • @SystemService
  • @ViewById
  • @ViewsById

🚫 @InstanceState
🚫 @FromHtml
🚫 @NonConfigurationInstance

The last annotations are not related to injection. :)

@WonderCsabo
Copy link
Member

I think all listed annotations are valid. And do not forget annotations from plugins (@RestClient).
@yDelouis do you agree?

@dodgex
Copy link
Member Author
dodgex commented Sep 23, 2015

so i need to find/create a common level of BaseAnnotationHandler where i can implement the method injection and it also needs to be available for plugins? :)

@WonderCsabo
Copy link
Member
WonderCsabo commented Sep 23, 2015 via email

@dodgex
Copy link
Member Author
dodgex commented Sep 26, 2015

currently broken, but that should be fixable with #1566

@yDelouis
Copy link
Contributor

I'm okay with the listed annotations. If we missed some, we could add them later.
The helper and the parent class are not incompatible. The parent class could use the helper so if we want a handler to extend another class, we can also add this feature to it.

@WonderCsabo
Copy link
Member

@dodgex this is no longer blocked.

@dodgex
Copy link
Member Author
dodgex commented Oct 11, 2015

@WonderCsabo i know, i already rebased after the blocker PR was merged. but i had no time yet to continue work on this.

@dodgex
Copy link
Member Author
dodgex commented Oct 11, 2015

@ViewById and @ViewsById depend of the release jcodemodel 2.7.12 see phax/jcodemodel#32. i have added 4 TODO notes for the update to 2.7.12 to remove some workarounds i added to have to code compiling right now.

@dodgex
Copy link
Member Author
dodgex commented Oct 11, 2015

same for @PreferenceByKey

@WonderCsabo
Copy link
Member

Some annotations are missing from plugins (OrmLiteDao, RestService,? )

@dodgex
Copy link
Member Author
dodgex commented Oct 11, 2015

arg... yeah. i think i have not checked the plugins when generating the above list of annotations todo.

@WonderCsabo
Copy link
Member

Are you planning to add those to this PR as well?

@dodgex
Copy link
Member Author
dodgex commented Oct 11, 2015

yeah. if it is ok.

WonderCsabo added a commit that referenced this pull request Dec 20, 2015
@WonderCsabo WonderCsabo merged commit ab53a8b into androidannotations:develop Dec 20, 2015
@WonderCsabo WonderCsabo added this to the 4.0 milestone Dec 20, 2015
@dodgex dodgex deleted the 204_method_injection branch December 20, 2015 12:30
@WonderCsabo
Copy link
Member

@dodgex can you update the wiki sometime?

@dodgex
Copy link
Member Author
dodgex commented Jan 4, 2016

I'll try to do it the next few days.

@dodgex
Copy link
Member Author
dodgex commented Jan 9, 2016

Checklist for Wiki Updates:

  • @App
  • @Bean
  • @Extra
  • @FragmentArg
  • @FragmentById
  • @FragmentByTag
  • @HttpsClient skipped
  • @InjectMenu
  • @OptionsMenuItem
  • @PreferenceByKey
  • @AnimationRes
  • @BooleanRes
  • @ColorRes
  • @ColorStateListRes
  • @DimensionPixelOffsetRes
  • @DimensionPixelSizeRes
  • @DimensionRes
  • @DrawableRes
  • @HtmlRes
  • @IntArrayRes
  • @IntegerRes
  • @LayoutRes
  • @MovieRes
  • @StringArrayRes
  • @StringRes
  • @TextArrayRes
  • @TextRes
  • @RootContext
  • @Pref
  • @SystemService
  • @ViewById
  • @ViewsById

@dodgex
Copy link
Member Author
dodgex commented Jan 9, 2016

wiki on my fork is updated. also i have added the commit 6ba5e68 that updates the year in FAQ to 2016. :)

@dodgex
Copy link
Member Author
dodgex commented Jan 9, 2016

added @RestService and @OrmLiteDao

@dodgex
Copy link
Member Author
dodgex commented Jan 15, 2016

@WonderCsabo I assume you missed that i updated the wiki?

@WonderCsabo
Copy link
Member
WonderCsabo commented Jan 15, 2016 via email

@dodgex
Copy link
Member Author
dodgex commented Jan 15, 2016

no problem

@WonderCsabo
Copy link
Member

I merged your wiki changes. Thanks again for your great work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0