Skip to content

Commit 48a6cd8

Browse files
committed
FIX: clean Android menu if center view has no menu items
1 parent 389492b commit 48a6cd8

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

WindowStack.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,22 @@ function WindowStack() {
4848
_window.fireEvent('open');
4949

5050
// Generate Android menu
51-
if (_window.hasOwnProperty('onCreateOptionsMenu')) {
52-
var activity = drawer.window.getActivity();
53-
activity.onCreateOptionsMenu = _window.onCreateOptionsMenu;
54-
55-
// Try to refresh menus
56-
try {
57-
activity.invalidateOptionsMenu();
58-
} catch (e) {
59-
Ti.API.warn('Maybe we still do not have activity to update the menu, it works now by the way');
51+
var activity = drawer.window.getActivity();
52+
53+
activity.onCreateOptionsMenu = function(e) {
54+
// Clean up all items from any other controller
55+
e.menu.clear();
56+
57+
if (_window.hasOwnProperty('onCreateOptionsMenu')) {
58+
_window.onCreateOptionsMenu(e);
6059
}
60+
};
61+
62+
// Try to refresh menus if the activity created
63+
try {
64+
activity.invalidateOptionsMenu();
65+
} catch (e) {
66+
Ti.API.warn('Maybe we still do not have activity to update the menu, it works now by the way');
6167
}
6268

6369
drawer.setCenterWindow(_window);

0 commit comments

Comments
 (0)