Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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

Copy link
Copy link
@mgajewski

Description

@mgajewski
Issue body actions

@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:

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.