Completely destroy a window - android

You must Login before you can answer or comment on any questions.

I am opening a window like so in my app.js

Ti.App.addEventListener('launchVforum', function(event)
{
    var vforum = Ti.UI.createWindow({
        url:'windows/vforum.js',
        vforumLocation:event.vforumLocation,
        vforumTitle:event.vforumTitle,
        username:event.username,
        navBarHidden:true,
        fullscreen:true
    });
 
    if (Ti.Platform.osname != "android")
    {
        vforum.modal = true;
    }
 
    vfTitleHolder = event.vforumTitle;
 
    vforum.open({modalTransitionStyle: Titanium.UI.iPhone.MODAL_TRANSITION_STYLE_COVER_VERTICAL});
    vforum.addEventListener('close',function(event)
    {
        Ti.API.error("settings vforum to null");
        vforum = null;  
    });
 
    Ti.App.addEventListener('closeVforum', function(event)
    {
        vfTitleHolder = '';
        vforum.close();
    });
});
That all works fine, the window opens and that's great. When I go back on android and reopen the vforum window, it opens again and thats good.

My issue is when I rotate the device, my orientationchange event that lives in vforum.js gets fired twice and causes my app to crash. As you can see above, I set vforum to null when it receives the close event. That even fires.

Inside vforum.js I even call a Ti.Gesture.removeEventListener('orientationchange', orientationHandler); when the window is closed. It still gets fired twice and the app crashes.

How can I completely destroy the vforum window when it is closed?

— asked 9 months ago by Ronnie Swietek
1 Comment
  • That's cool...if you're going to give a down vote at least explain why. Anyway, I've fixed it by moving var vforum out of the event. The problem was it was creating a new vforum window every time the event fired. I was under the impression that the close method got rid of the window

    — commented 9 months ago by Ronnie Swietek

Your Answer

Think you can help? Login to answer this question!