[TIMOB-1256] Titanium.Media.openPhotoGallery's callbacks only work once when multiple contexts involved.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:55:40.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.5.0 |
Components | Android |
Labels | android, defect |
Reporter | Bill Dawson |
Assignee | Don Thorp |
Created | 2011-04-15T02:47:53.000+0000 |
Updated | 2011-04-17T01:55:40.000+0000 |
Description
It could be that this is sensitive to a different context than the one which created the Titanium.Media singleton (maybe not related to that, but it's my guess.) Simple test: two JS's, starting with app.js:
Titanium.UI.setBackgroundColor('#000');
var main = Titanium.UI.createWindow({
backgroundColor:'#fff',
fullscreen: true
});
var btn = Ti.UI.createButton({
title: 'Open test window'
});
btn.addEventListener('click', function(e) {
var w = Ti.UI.createWindow({
url: 'win1.js',
backgroundColor: 'black',
fullscreen:true
});
w.open();
});
main.add(btn);
main.open();
And win1.js:
var win = Ti.UI.currentWindow;
Ti.Media.openPhotoGallery({
success: function() {Ti.API.info('success');},
cancel: function() {Ti.API.info('cancel');},
error: function() {Ti.API.info('error');}
});
var btn = Ti.UI.createButton({ title: 'close' });
btn.addEventListener('click', function() {win.close();});
win.add(btn);
First time you go to the photo gallery, the callbacks will work. Next time not.
Behavior can also be seen in Phone -> Photo Gallery test in KS.
FYI, when the @ContextSpecific annotation (which I haven't pushed yet) is applied to MediaModule, and therefore the module "singleton" is at the context rather than application level, it works correctly.
I need this feature for a client, Is there a way to get this change you made?
I rebuilt the code using Bill's fix and it seems to work fine.
@ContextSpecific public class MediaModule extends TiModule
Thanks
(from [6120037dfd4e15f287cb9c058414ee79d55678c5]) [#1256 state:fixed-in-qa]: Make media module context-specific so that openPhotoGallery() callbacks will continue to work even after new windows are opened. http://github.com/appcelerator/titanium_mobile/commit/6120037dfd4e15f287cb9c058414ee79d55678c5"> http://github.com/appcelerator/titanium_mobile/commit/6120037dfd4e1...
confirmed fixed in 1.4.1
valid, needs testcase