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.

@InjectMenu gives not inflated Menu object #1961

Description

@mgajewski

@InjectMenu annotation gives not inflated Menu object. In generated code menu is inflated after it's set into annotated function. Menu object is not null but it's useless as it is not ready menu object.

AndroidAnnotations version:
4.2.0

Android compile SDK version:
25

Annotated code:

@EActivity(R.layout.activity_main)
@OptionsMenu(R.menu.main_menu)
public class MainActivity extends AppCompatActivity {
    @InjectMenu
    void setMenu(Menu mainMenu) {
        //mainMenu is not inflated here!
    }
}

Expected generated code:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.main_menu, menu);
        {
            Menu mainMenu = null;
            mainMenu = menu;
            setMenu(mainMenu);
        }
        return super.onCreateOptionsMenu(menu);
    }

Actual generated code:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater menuInflater = getMenuInflater();
        {
            Menu mainMenu = null;
            mainMenu = menu;
            setMenu(mainMenu);
        }
        menuInflater.inflate(R.menu.main_menu, menu);
        return super.onCreateOptionsMenu(menu);
    }

Stacktrace in case of AA crash:

Activity

  1. changed the title [-]@InjectMenu gives null Menu object[/-] [+]@InjectMenu gives not inflated Menu object[/+] on Mar 5, 2017
  2. dodgex commented on Mar 5, 2017

    @dodgex
    Member

    Thank you for the report. I opened a PR with a fix.

  3. self-assigned this
    on Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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