Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1256] Titanium.Media.openPhotoGallery's callbacks only work once when multiple contexts involved.

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:55:40.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
ComponentsAndroid
Labelsandroid, defect
ReporterBill Dawson
AssigneeDon Thorp
Created2011-04-15T02:47:53.000+0000
Updated2011-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.

Comments

  1. Bill Dawson 2011-04-15

    Behavior can also be seen in Phone -> Photo Gallery test in KS.

  2. Bill Dawson 2011-04-15

    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.

  3. Fazal Mohammed 2011-04-15

    I need this feature for a client, Is there a way to get this change you made?

  4. Fazal Mohammed 2011-04-15

    I rebuilt the code using Bill's fix and it seems to work fine.

    @ContextSpecific public class MediaModule extends TiModule

    Thanks

  5. Jeff Haynie 2011-04-15

    (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...

  6. Thomas Huelbert 2011-04-15

    confirmed fixed in 1.4.1
    valid, needs testcase

JSON Source