Skip to content
Browse files

1) Since we're always keeping niles in the display tree and just flip…

…ping their visibility, a'la a viewstack, logic could be simplified in NileContainer.

2) Added some more asserts.
  • Loading branch information...
1 parent 00a5496 commit cabf65af621a83667437d6ab48cc6d8ace88ee60 @jubishop committed
Showing with 16 additions and 10 deletions.
  1. +4 −1 fbair.mxml
  2. +12 −9 fbair/nile/NileContainer.mxml
View
5 fbair.mxml
@@ -113,6 +113,9 @@
// If we have tabs data, hit it up
var filtersData:Object = ApplicationBase.getPreference("filters");
if (filtersData) {
+ Output.assert(nileCache != null,
+ "We have a filter cache but not a nile cache?!");
+
// Set nile stuff first to prepare for events
var stream_filters:Array = new Array();
for each (var tab:Object in filtersData.tabData)
@@ -126,7 +129,7 @@
filtersBar.currentTab = filtersData.currentTab;
}
}
-
+
// We want to listen to changes to status or permissions,
// so let's add event listeners for both.
FBConnect.dispatcher.addEventListener(FBEvent.STATUS_CHANGED,
View
21 fbair/nile/NileContainer.mxml
@@ -122,19 +122,24 @@
// Add our initial nile to the canvas
nile.visible = false;
nile.addEventListener(Event.RESIZE, boundNile);
+ nileCanvas.addChild(nile);
}
// We call this on launch to set up our initial set of filters, if cached
+ // dataCache should already be set now as well
public function loadInitialFilters(stream_filters:Array):void {
// Blow away any defaults since we have cache
CurrentFilter = null;
niles = new Object();
nile.removeEventListener(Event.RESIZE, boundNile);
+ nileCanvas.removeChild(nile);
nile = null;
// Populate our filters and their niles
streamFilters = stream_filters;
for each (var streamFilter:String in streamFilters) {
+ Output.assert(dataCache[streamFilter] != null,
+ "Loading streamFilter with no dataCache entry? : " + streamFilter);
niles[streamFilter] = new Nile();
niles[streamFilter].visible = false;
niles[streamFilter].addEventListener(Event.RESIZE, boundNile);
@@ -173,9 +178,11 @@
public function beginPolling():void {
if (FBConnect.status != FBConnect.Connected) return;
+ // Begin our polling routine
pollingTimer.addEventListener(TimerEvent.TIMER, poll);
poll();
+ // Show the nile to the world!
nile.visible = true;
}
@@ -350,7 +357,8 @@
niles[filter_key] = new Nile();
nile = niles[filter_key];
nile.addEventListener(Event.RESIZE, boundNile);
-
+ nileCanvas.addChild(nile);
+
// poll baby!
fbair.loadingIndicator.loadStatus("Fetching Stream Data");
poll();
@@ -364,14 +372,15 @@
var filter_index:int = streamFilters.indexOf(filter_key);
Output.assert(filter_index != -1, "Removing filter with index -1?: " +
filter_key);
+ Output.assert(nileCanvas.contains(niles[filter_key]),
+ "Removing nile not in display?");
Output.assert(niles[filter_key] != null,
"Removing filter that had no nile?: " + filter_key);
// Remove nile itself
niles[filter_key].removeEventListener(Event.RESIZE, boundNile);
if (nile == niles[filter_key]) nile = null;
- if (nileCanvas.contains(niles[filter_key]))
- nileCanvas.removeChild(niles[filter_key]);
+ nileCanvas.removeChild(niles[filter_key]);
delete niles[filter_key];
// Remove from filters
@@ -395,12 +404,6 @@
// Add new nile
nile = niles[filter_key];
nile.visible = true;
- Animate = false;
- if (!nileCanvas.contains(nile))
- nileCanvas.addChild(nile);
-
- // Mark this as an update in case new data hits fast
- updateTime = (new Date()).time;
}
}

0 comments on commit cabf65a

Please sign in to comment.
Something went wrong with that request. Please try again.