Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.

Problem using it with AndroidAnnotations #61

Closed
gdogaru opened this issue Feb 15, 2013 · 16 comments
Closed

Problem using it with AndroidAnnotations #61

gdogaru opened this issue Feb 15, 2013 · 16 comments
Milestone

Comments

@gdogaru
Copy link

gdogaru commented Feb 15, 2013

I tried using dagger with AndroidAnnotations within activities.
The problem is that AndroidAnnotations creates a subclass of my activity.
When you look for annotated subscribers in com.squareup.otto.AnnotatedHandlerFinder#loadAnnotatedMethods you use listenerClass.getDeclaredMethods()
This does not return the methods from the super-class. So I can not receive messages if I create a subclass of the class that contains subscribe methods.
I got around this by registering an anonymous class with an annotated method.
Not sure if you want to support this, just mentioned it.
Thanks,
Gabi

@JakeWharton
Copy link
Collaborator

This will come with 2.0 when class hierarchy walking is restored. This was intentionally removed for the 1.x versions.

@bensandee
Copy link
Contributor

I appreciate the decision, and it's easy enough to work around with enough care.

That said, gIven how easy it is to accidentally subscribe to events in a class and then subclass it, I wonder if either of these would be useful:

  • a warning could be logged (difficult, since you've kept dependencies minimal and there's no logging)
  • a "strict" flag for the Bus, where an IllegalArgumentException might be thrown
    if you try to subscribe to events using a non-final class.

In my code base, this is effectively what I've tried to do to avoid accidentally losing events.

@bensandee
Copy link
Contributor

So, quick experiment leads me to the fact that anonymous inner classes are non-final (I'm sure there's a good reason). Oh well.

@imminent
Copy link
Contributor

@JakeWharton I seem to have an error with unregistering Subscribers using 2.0 snapshot. It's the IllegalArugmentException "Missing Subscriber...". Do you have to handle subscription differently in 2.0?

@JakeWharton
Copy link
Collaborator

I wasn't even aware 2.0 compiled, to be honest.

@imminent
Copy link
Contributor

The clean android code project uses it because the change is necessary for
integration with AndroidAnnotations, isn't it?
On Feb 27, 2013 1:39 PM, "Jake Wharton" [email protected] wrote:

I wasn't even aware 2.0 compiled, to be honest.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-14201821
.

@JakeWharton
Copy link
Collaborator

Yes, but it's a long way from actually being a shippable version of the library. It doesn't surprise me at all that there are problems with it. I wouldn't recommend using it until we move it to the master branch to dictate that it's relatively stable and pushing toward release.

@imminent
Copy link
Contributor

That's what I was afraid of. I thought I would give it a try to find out
though. Would love to have these libraries working together. I'm all for
readable, maintainable code.
On Feb 27, 2013 2:07 PM, "Jake Wharton" [email protected] wrote:

Yes, but it's a long way from actually being a shippable version of the
library. It doesn't surprise me at all that there are problems with it. I
wouldn't recommend using it until we move it to the master branch to
dictate that it's relatively stable and pushing toward release.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-14203331
.

@JakeWharton
Copy link
Collaborator

Well I'm starting actual 2.0 development today or tomorrow so it should move forward quickly. As it exists now it's more of a proof-of-concept.

@imminent
Copy link
Contributor

Oh, awesome! Is there anything I can follow to see if I can contribute to
its progress. Annotation processing is a bit outside my usual domain. These
issues are for the whole repository, not just a branch, right?
On Feb 27, 2013 2:14 PM, "Jake Wharton" [email protected] wrote:

Well I'm starting actual 2.0 development today or tomorrow so it should
move forward quickly. As it exists now it's more of a proof-of-concept.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-14203713
.

@JakeWharton
Copy link
Collaborator

All issues relevant to its development will be organized on the 2.0 milestone of the project.

@JakeWharton
Copy link
Collaborator

I need to rebase it first, though, since the branch is about 6 months out of date.

@imminent
Copy link
Contributor

Got it.
On Feb 27, 2013 2:21 PM, "Jake Wharton" [email protected] wrote:

I need to rebase it first, though, since the branch is about 6 months out
of date.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-14204069
.

@WonderCsabo
Copy link

@JakeWharton what is the status of the 2.0 branch? Did you reject to continue development in that way?

@JakeWharton
Copy link
Collaborator

Nobody is working on it. We have no plans to release 2.0 at this time.
On May 28, 2014 12:24 PM, "Csaba Kozák" [email protected] wrote:

@JakeWharton https://github.com/JakeWharton what is the status of the
2.0 branch? Did you reject to continue development in that way?


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-44452825
.

@JakeWharton
Copy link
Collaborator

#135 will restore hierarchy walking.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants