[TIMOB-4897] Android: Setting navBarHidden:false in window creation causes event listeners on a module to stop working
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2011-08-31T14:54:31.000+0000 |
Affected Version/s | Release 1.7.2 |
Fix Version/s | Sprint 2011-35 |
Components | Android |
Labels | n/a |
Reporter | Jeff English |
Assignee | Bill Dawson |
Created | 2011-08-05T05:45:22.000+0000 |
Updated | 2014-06-19T12:46:34.000+0000 |
Description
I have confirmed that the issue occurs simply by adding 'navBarHidden:false' to the window creation. If you comment out the setting of the navBarHidden property then the event listeners work.
The sample below is excerpted from MOD-149. You should be able to just take the sample in the barcode module and add the navBarHidden property to the window creation.
Android Barcode module not receiving event listeners. Use sample code for testing:
var window = Ti.UI.createWindow({
backgroundColor: 'white',
layout: 'vertical',
navBarHidden:false,
exitOnClose:true
});
var button = Ti.UI.createButton({
title: 'Scan Code',
width: 150,
height: 60,
top: 20
});
window.add(button);
window.add(Ti.UI.createLabel({
text: 'You may need to rotate the device',
top: 10,
height: 'auto', width: 'auto',
font: { fontSize: 12 }
}));
window.add(Ti.UI.createLabel({
text: 'Result:',
top:10,
left:10,
textAlign: 'left',
color:'black',
font: {fontSize:18, fontStyle:'bold'},
height:'auto'
}));
var scanResult = Ti.UI.createLabel({
text: '',
top:10,
left:10,
textAlign: 'left',
color:'black',
height:'auto'
});
window.add(scanResult);
window.add(Ti.UI.createLabel({
text: 'Content Type:',
top:10,
left:10,
textAlign: 'left',
color:'black',
font: {fontSize:18, fontStyle:'bold'},
height:'auto'
}));
var scanContentType = Ti.UI.createLabel({
text: '',
top:10,
left:10,
textAlign: 'left',
color:'black',
height:'auto'
});
window.add(scanContentType);
window.add(Ti.UI.createLabel({
text: 'Format:',
top:10,
left:10,
textAlign: 'left',
color:'black',
font: {fontSize:18, fontStyle:'bold'},
height:'auto'
}));
var scanFormat = Ti.UI.createLabel({
text: '',
top:10,
left:10,
textAlign: 'left',
color:'black',
height:'auto'
});
window.add(scanFormat);
window.open();
Titanium.Barcode = Ti.Barcode = require('ti.barcode');
button.addEventListener('click', function() {
Ti.Barcode.capture();
});
Ti.Barcode.addEventListener('error', function(e) {
scanResult.text = e.message;
scanContentType.text = '';
scanFormat.text = '';
});
Ti.Barcode.addEventListener('canceled', function(e) {
scanResult.text = e.message;
scanContentType.text = '';
scanFormat.text = '';
});
Ti.Barcode.addEventListener('success', function(e) {
scanResult.text = e.result;
scanContentType.text = e.contentType;
scanFormat.text = e.format;
alert("result: "+e.result);
});
Updated module source to retrieve activity from KrollInvocation. No change required in core platform.