Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2769] sequential use of openPhotoGallery with imageview.

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-04-10T22:27:20.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsimage, imageview
Reportermarzpet vardanyan
AssigneeJunaid Younus
Created2012-03-11T03:45:48.000+0000
Updated2016-03-08T07:47:40.000+0000

Description

I was trying to let the user select an image from the gallery then show it in an imageview befor sending it over to my server. the window that contains the imageview has a back button(confirmationWindow.close()) to cancel and start over. the first time is no problem the image loads perfectly but then it starts to get buggy and sometimes the image isn't visible. is this a bug? or am I doing something wrong?
Titanium.Media.openPhotoGallery({
            success: processImage,
            cancel: function(){return false;},
            error: imageFailed,
        });
 
function processImage(image){
    //remove previously added image
    var children = imageHolder.children.slice(0);
    for (var i = 0; i < children.length; ++i) {
        imageHolder.remove(children[i]);
    }
     // place our picture into our window
    imageHolder.add(Ti.UI.createImageView({
        transform: Ti.UI.create2DMatrix().scale(1),
        center: {x: '50%', y: '50%'},
        image: image.media,
    }));
    imageviewer.open();
    //imageHolder.add(webview);
    Titanium.App.imageBlob = image.media;
    /*
     * rotate image
     */
    var cropRect = image.cropRect;    
    var height = cropRect.height;
    var width = cropRect.width;
    alert("base64=" + image.media.toString());
    if(height> width){
        //imageView.transform = Titanium.UI.create2DMatrix({rotate: -90,duration: 1,}); 
    }
    return false;
 
}

Comments

  1. Federico Casali 2012-04-01

    Hi Marzpet - I've not been able to reproduce the issue starting from your sample code. This is how I adapted your sample code:http://pastie.org/3712949 It would be possible for you to post a whole runnable portion of code reproducing your problem? I'm missing a few objects (imageviewer for example). Thanks
  2. Junaid Younus 2012-04-09

    Hey Marzpet, I don't seem to be able to reproduce this issue with your given code either. Any chance you could attach a working sample project that reproduces the problem? This will help us fix this bug asap. Thank you! Junaid
  3. Edgard Zavarezzi 2012-06-11

    I'm also having similar issues. When calling openPhotoGallery and selecting a picture, it works only two times, then freeze on the Move and Scale view. Code: var pictureDialog = Ti.UI.createOptionDialog({ cancel: 2, options: ['Gallery', 'Camera', 'Cancel'], title: 'Select' }); pictureMoldura.addEventListener('click', function(e) { pictureDialog.show(); pictureDialog.addEventListener('click', function(e) { switch(e.index) { case 0: Titanium.Media.openPhotoGallery( { success:function(event) { }, error:function(error) { Ti.API.debug(error); }, allowEditing:true, mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO] }); break; ...
  4. Edgard Zavarezzi 2012-06-12

    It looks like the error is occurring when using an OptionDialog to call the photoGallery. Recreating the optionDialog every time seems to solve the problem: button.addEventListener('click', editPicture); function editPicture(e) { var pictureDialog = null; var pictureDialog = Ti.UI.createOptionDialog({ cancel: 2, options: ['Gallery', 'Camera', 'Calcel'], title: 'Select' }); pictureDialog.addEventListener('click', function(e) { switch(e.index) { case 0: Titanium.Media.openPhotoGallery( ... break; case 1: Titanium.Media.showCamera( ... break; } }); }); pictureDialog.show(); }

JSON Source