[TIMOB-12651] Android: Standardize error reporting in callbacks and events
| GitHub Issue | n/a | 
|---|---|
| Type | Story | 
| Priority | Medium | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2013-03-29T21:38:28.000+0000 | 
| Affected Version/s | n/a | 
| Fix Version/s | Release 3.1.0, 2013 Sprint 07 API, 2013 Sprint 07 | 
| Components | Android | 
| Labels | api | 
| Reporter | Ingo Muschenetz | 
| Assignee | Ingo Muschenetz | 
| Created | 2013-02-08T22:32:22.000+0000 | 
| Updated | 2017-03-22T00:16:56.000+0000 | 
Progress tracker: https://github.com/BlainHamon/titanium_mobile/compare/timob-12651
Another test case to verify the new events are working correctly: 1. Run the following code and click 'launch camera'
// this sets the background color of the master UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#000'); // create base UI tab and root window // var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var button = Ti.UI.createButton({ title:'launch camera', width:200, height:100 }); button.addEventListener('click', function(){ Titanium.Media.showCamera({ success:function(event) { }, cancel:function(e) { Ti.API.info('---------- keys: ' + Object.keys(e)); Ti.API.info('---------- code: ' + e.code); Ti.API.info('---------- success: ' + e.success); }, error:function(error) { }, saveToPhotoGallery:true, allowEditing:true, mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO] }); }); win1.add(button); win1.open();Actual results: Runtime error since e is undefined before this change.Another test case as a sanity check to make sure events aren't broken after this change: 1. Run the following code and click on 'play sound'
var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var button = Ti.UI.createButton({ title:'play sound', width:200, height:100 }); button.addEventListener('click', function(){ var player = Ti.Media.createSound({url:"cricket.wav"}); player.addEventListener('complete', function(e){ Ti.API.info('------------------------' + e.type); Ti.API.info('------------------------' + e.source); Ti.API.info('------------------------' + e.bubbles); Ti.API.info('------------------------' + e.cancelBubble); }) player.play(); }); win1.add(button); win1.open();After looking through the docs, there are some places where Android doesn't generate error issues even though it should have.
Looks like the 'heading' event from geolocation module, and 'completed' event from sound proxy doesn't have have the error codes.
Furthermore, Ti.Media.VideoPlayerProxy has the following issues: * Error event is missing code, success, and error. (MW, MW and Android documentation) * Complete event is missing code, success, and error. (Android, iOS, MW, and all documentation)
https://github.com/appcelerator/titanium_mobile/pull/4034
test case with video player to verify that it has the correct event properties after the change:
var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var videoPlayer = Titanium.Media.createVideoPlayer({ top : 2, autoplay : true, backgroundColor : 'blue', height : 300, width : 300, mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT, scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT }); videoPlayer.url = 'movie.mp4'; videoPlayer.addEventListener('complete', function(e){ Ti.API.info('------------------------' + e.type); Ti.API.info('------------------------' + e.source); Ti.API.info('------------------------' + e.bubbles); Ti.API.info('------------------------' + e.cancelBubble); Ti.API.info('------------------------' + Object.keys(e)); }) win1.add(videoPlayer); win1.open();Pull https://github.com/appcelerator/titanium_mobile/pull/4034 merged
Follow-up PR: https://github.com/appcelerator/titanium_mobile/pull/4069
Closing ticket as fixed.