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.

A bug If I have the same method name  #591

Description

@Tanlet

Sorry for my awful English.
Thanks to your work!AndroidAnnotation is a great project.I like this so muck.But I think I find a bug in my project.

Class 1:

@EActivity
public class Test1 extends Activity {
    @AfterViews
    public void init() {
        Log.v("","Word");
    }
}

Class 2:

@EActivity
public class Test2 extends Test1 {
    @AfterViews
    public void init() {
        Log.v("","Hello");
    }
}

The result is twice "Hello".
The reason is easy to find.
In the Test2_,We find this:

private void afterSetContentView_() {
      text = ((TextView) findViewById(id.text));
      init();
      init();
}

The right result is :

private void afterSetContentView_() {
     text = ((TextView) findViewById(id.text));
     init();
     supper.init();
}

Of course ,If you rename init() in Test2 to init2().It will work well.

Activity

  1. DayS commented on May 18, 2013

    @DayS
    Contributor

    I think you're talking about the comment I added on issue #553 . But I think you made a mistake on your example : Test2 should extends of Test1 and not Activity to have this bug

    Note: I updated your post to improbe lisibility by using github markdown.

  2. mathieuboniface commented on May 18, 2013

    @mathieuboniface
    Contributor

    I'm not sure we can fix that issue...

    The workaround is to have a different method name for each method annotated with @AfterViewsin the class hierarchy.

    I'm closing that issue, please reopen if you have an idea to fix that issue...

  3. Tanlet commented on May 19, 2013

    @Tanlet
    Author

    I so sad to hear that.But we should mark a note in the wiki

  4. DayS commented on May 19, 2013

    @DayS
    Contributor

    I updated the wiki

  5. DavidDTA commented on Feb 16, 2016

    @DavidDTA

    Half of this check can be performed with the @CallSuper support annotation. The other half would be to ensure that @AfterViews is not put on a method and an override of that method.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions