[TIMOB-1742] Android: Window in TabGroup loses event listeners
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:57:02.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.6.0 M07 |
Components | Android |
Labels | android, back, backbutton, button, close, defect, event, eventlistener, listener, release-1.6.0, tabGroup, tabgroup |
Reporter | Lukasz |
Assignee | Jeff Haynie |
Created | 2011-04-15T03:01:04.000+0000 |
Updated | 2011-04-17T01:57:02.000+0000 |
Description
This is similar problem to "Android: Window Closed with Back Button Won't Reopen" (https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/1470">https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobi...) but this happens if you use TabGroups instead Windows.
- Create two TabGroups with two windows.
- Attach a click event listener to the window in first TabGroup.
This listener should open the second TabGroup.
- Open first TabGroup.
- Click on window and activate listener.
- Second TabGroup will open.
- Click Android back button, this will close second
TabGroup.
- Click on window and activate listener. Nothing happens.
Testcase:
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup1 = Titanium.UI.createTabGroup();
var tabGroup2 = Titanium.UI.createTabGroup();
// create base UI tab and root window
var win1 = Titanium.UI.createWindow({
navBarHidden:false,
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{
fontSize:20,
fontFamily:'Helvetica Neue'
},
textAlign:'center',
width:'auto'
});
win1.add(label1);
// create controls tab and root window
var win2 = Titanium.UI.createWindow({
navBarHidden:false,
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
window:win2
});
var label2 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 2',
font:{
fontSize:20,
fontFamily:'Helvetica Neue'
},
textAlign:'center',
width:'auto'
});
win2.add(label2);
// add tabs
tabGroup1.addTab(tab1);
tabGroup1.addTab(tab2);
// open first tab group
tabGroup1.open();
// create base UI tab and root window
var win3 = Titanium.UI.createWindow({
navBarHidden:false,
title:'Tab 3',
backgroundColor:'#fff'
});
var tab3 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 3',
window:win3
});
var label3 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 3',
font:{
fontSize:20,
fontFamily:'Helvetica Neue'
},
textAlign:'center',
width:'auto'
});
win3.add(label3);
// create controls tab and root window
var win4 = Titanium.UI.createWindow({
navBarHidden:false,
title:'Tab 4',
backgroundColor:'#fff'
});
var tab4 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 4',
window:win4
});
var label4 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 4',
font:{
fontSize:20,
fontFamily:'Helvetica Neue'
},
textAlign:'center',
width:'auto'
});
win4.add(label4);
// add tabs
tabGroup2.addTab(tab3);
tabGroup2.addTab(tab4);
// attach click listener
win1.addEventListener('click', function(){
// this will fire only once
Ti.API.debug('fired click listener!');
tabGroup2.open();
});
Trace:
// first click
[TRACE] E/TiUIView( 2146): (main) [8045,11705] TAP, TAP, TAP
[DEBUG] [28,11733] fired click listener!
[TRACE] I/TabGroupProxy( 2146): (main) [8,11741] handleOpen
[TRACE] I/ActivityManager( 61): Starting activity: Intent { cmp=com.AndroidBackButton/ti.modules.titanium.ui.TiTabActivity (has extras) }
[TRACE] D/PhoneWindow( 2146): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@43e92980 has no id.
[TRACE] W/TiTabActivity( 2146): (main) [104,11845] Notifying TiTabGroup, activity is created
[TRACE] W/TiActivity( 2146): (main) [198,12043] Notifying TiUIWindow, activity is created
[TRACE] I/ActivityManager( 61): Displayed activity com.AndroidBackButton/ti.modules.titanium.ui.TiTabActivity: 417 ms (total 417 ms)
// back button
[TRACE] W/KeyCharacterMap( 2146): No keyboard for id 0
[TRACE] W/KeyCharacterMap( 2146): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
[TRACE] E/TiActivity( 2146): (main) [4082,16125] Layout cleanup.
// second click
[TRACE] E/TiUIView( 2146): (main) [2329,18454] TAP, TAP, TAP
EDITED:
Tested with mobilesdk-1.4.1-20100904221103-osx.zip
Attachments
File | Date | Size |
---|---|---|
app.js | 2011-04-15T03:01:05.000+0000 | 3761 |
We need to check this with the new Kroll.
Another similar ticket 'Android: event listeners in reopened window do not fire.' https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/1767"> https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobi...
I've changed a little bit fail case. I've added a button to the first window. If you open and close (with back button) the second tab group also the button loses its listener.
Tested with newest build: mobilesdk-1.4.1-20100909194301-osx.zip
Is there ANY chance to solve this?
We're still working on the kroll rewrite, but we're getting closer to a first pass. We will use this as a test case.
Please verify of still an issue in 1.6. If so talk with me so we can see if it can be fixed in time.
Issue resolved via #2640. The app needs to be modified to use the {exitOnClose: false} option when creating the second tab group otherwise closing the tab would result in the root activity being closed.
I update the test app to call tabGroup1.open() only once and also to set the exitOnClose flag. The issue can be verified by:
1) Run attached test app.js
2) click button and check log to verify event is fired
3) double click on main window of tab 1 to open tab group 2
4) hit the back button to close tab group 2 and return to tab group 1
5) click button and check log to verify event will still fire
Thanks
Opie
If I follow the script above it works. If I do what the test says and double-click on the second tab group. It crashes with.
Fixed test to address error found by Don.
New test attached.
Emulator 2.2, ba41eca7d
Verified the updated app.js ...