0

i am new to titanium development,i am selecting an image from gallery after selecting image i need to open the another window.but after click the choose it will taking time to open the next screen.

User will confusing after choose previous window displaying then new screen will coming please help me how to resolve.

below is my code :

 Titanium.Media.openPhotoGallery({
       success:function(event){
           Ti.API.info('   in openPhotoGallery   success  ');   
           var imageBase64String=Ti.Utils.base64encode(event.media).toString();
           var args={base64String : imageBase64String };
           Alloy.createController('customerTagPost', args).getView().open(); 
       },
       cancel:function(){
       // user cancelled the action fron within
       // the photo gallery
       },    
       allowEditing:true,
       mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]
       }); 
Fokke Zandbergen
  • 3,866
  • 1
  • 11
  • 28
Balu
  • 57
  • 6
  • How much time are we talking about? Are you trying to take the selected image to open in the new window? – Sharif Abu Darda Mar 08 '16 at 14:08
  • I am selecting the image from gallery, converted into base64string and passed to the next window. in device getting some delay to open the next window please help me – Balu Mar 08 '16 at 14:46
  • Can you attach the full code that you are trying? – Sharif Abu Darda Mar 08 '16 at 20:57
  • Titanium.Media.openPhotoGallery({success:function(event){var imageBase64String=Ti.Utils.base64encode(event.media).toString();var args={base64String : imageBase64String }; Alloy.createController('customerTagPost', args).getView().open(); },cancel:function(){ },allowEditing:true,mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]}); } else{}}); – Balu Mar 09 '16 at 08:35
  • I've updated the code in your question to include this essential information. – Fokke Zandbergen Mar 10 '16 at 12:01

1 Answers1

1

Since Ti.Utils.base64encode() is a synchronous and expensive operation, Titanium will wait for it to be finished before it can get to create the controller and open it's window.

I'd suggest you first open the Window, then encode the image and pass it to the Window controller via an exposed method.

Fokke Zandbergen
  • 3,866
  • 1
  • 11
  • 28
  • Hi Fokke, Thanks for your suggestion now some time reduced it's opening new window some quickly. but still previous screen is visible.i don't want to see the previous screen. please help me. After selecting the choose directly i want to go to the next window. – Balu Mar 18 '16 at 07:19
  • What do you mean by the previous screen is still visible? Do you have a screenshot or screenrecording? – Fokke Zandbergen Mar 18 '16 at 09:23