Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12651] Android: Standardize error reporting in callbacks and events

GitHub Issuen/a
TypeStory
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-03-29T21:38:28.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.1.0, 2013 Sprint 07 API, 2013 Sprint 07
ComponentsAndroid
Labelsapi
ReporterIngo Muschenetz
AssigneeIngo Muschenetz
Created2013-02-08T22:32:22.000+0000
Updated2017-03-22T00:16:56.000+0000

Description

Comments

  1. Blain Hamon 2013-02-13

    Progress tracker: https://github.com/BlainHamon/titanium_mobile/compare/timob-12651
  2. Allen Yeung 2013-02-28

  3. Allen Yeung 2013-03-04

    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();
       
    2. After the camera launches, push cancel 3. Look at logcat for results Expected Result:
       I/TiAPI   ( 9991):  ---------- keys: code,success
       I/TiAPI   ( 9991):  ---------- code: 0
       I/TiAPI   ( 9991):  ---------- success: true
       
    Actual results: Runtime error since e is undefined before this change.
  4. Allen Yeung 2013-03-04

    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();
       
    2. After the sound completes, look at logcat and you should see the following:
       I/TiAPI   (13949):  ------------------------complete
       I/TiAPI   (13949):  ------------------------[object Sound]
       I/TiAPI   (13949):  ------------------------false
       I/TiAPI   (13949):  ------------------------false
       
  5. Blain Hamon 2013-03-23

    After looking through the docs, there are some places where Android doesn't generate error issues even though it should have.
  6. Allen Yeung 2013-03-23

    Looks like the 'heading' event from geolocation module, and 'completed' event from sound proxy doesn't have have the error codes.
  7. Blain Hamon 2013-03-25

    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)
  8. Blain Hamon 2013-03-28

    https://github.com/appcelerator/titanium_mobile/pull/4034
  9. Allen Yeung 2013-03-29

    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();
       
    Expected Result:
       I/TiAPI   (13216):  ------------------------complete
       I/TiAPI   (13216):  ------------------------[object VideoPlayer]
       I/TiAPI   (13216):  ------------------------true
       I/TiAPI   (13216):  ------------------------false
       I/TiAPI   (13216):  ------------------------type,source,reason,bubbles,success,code,error,cancelBubble
       
  10. Vishal Duggal 2013-03-29

    Pull https://github.com/appcelerator/titanium_mobile/pull/4034 merged
  11. Allen Yeung 2013-04-04

    Follow-up PR: https://github.com/appcelerator/titanium_mobile/pull/4069
  12. Lee Morris 2017-03-22

    Closing ticket as fixed.

JSON Source