Skip to content

Instantly share code, notes, and snippets.

@tonylukasavage
Created November 5, 2012 17:25
Show Gist options
  • Save tonylukasavage/4018538 to your computer and use it in GitHub Desktop.
Save tonylukasavage/4018538 to your computer and use it in GitHub Desktop.
Memory management fix
function openView1(e)
{
// $.view1 = Alloy.createController('view1'); // create controller
// $.rootwindow.add($.view1.getView()); // add View1 to Window
// VARS.GVUpdate("globalCurrentView", $.view1.getView()); // Update ref to view2
var view1 = Alloy.createController('view1'); // create controller
$.rootwindow.add(view1.getView()); // add View1 to Window
VARS.GVUpdate("globalCurrentView", view1.getView()); // Update ref to view2
}
var VARS = require('Globals'); // Ref Globals
VARS.GVUpdate("globalParent", $.rootwindow); // Update Parent to store ref to Window
// open Main App Window
$.rootwindow.open();
function openView2(e)
{
var VARS = require('Globals'); // Ref Globals
// $.view2 = Alloy.createController('view2'); // Ref View2 to load it
// VARS.GV.globalParent.add($.view2.getView()); // Add View 2 to Window
var view2 = Alloy.createController('view2'); // Ref View2 to load it
VARS.GV.globalParent.add(view2.getView()); // Add View 2 to Window
// remove view 1
VARS.GVUpdate("closeView", new VARS.GV.CloseView(VARS.GV.globalParent, VARS.GV.globalCurrentView));
VARS.GVUpdate("closeView", null);
VARS.GVUpdate("globalCurrentView", view2.getView()); // Update ref to view2
}
function closeView2(e)
{
// reopen view1 and add to window
var VARS = require('Globals'); // Ref Globals
// $.view1 = Alloy.createController('view1'); // Ref View1 to load it
// VARS.GV.globalParent.add($.view1.getView()); // Add View 1 to Window
var view1 = Alloy.createController('view1'); // Ref View1 to load it
VARS.GV.globalParent.add(view1.getView()); // Add View 1 to Window
// close view 2
var VARS = require('Globals');
VARS.GVUpdate("closeView", new VARS.GV.CloseView(VARS.GV.globalParent, VARS.GV.globalCurrentView));
VARS.GVUpdate("closeView", null);
// VARS.GVUpdate("globalCurrentView", $.view1.getView()); // Update ref to view1
VARS.GVUpdate("globalCurrentView", view1.getView()); // Update ref to view1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment