Skip to content

Commit

Permalink
Merge branch 'master' of github.com:funkatron/Spaz-Enyo
Browse files Browse the repository at this point in the history
  • Loading branch information
eberon committed Aug 30, 2011
2 parents 02fc32d + c90b5bb commit 3786176
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions source/javascript/Spaz.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enyo.kind({
{kind: enyo.ApplicationEvents, onApplicationRelaunch: "relaunchHandler",
onWindowActivated:"windowActivated", onWindowDeactivated:"windowDeactivated",
onUnload:"unloaded"},
{name: "alarmService", kind: "PalmService", service: "palm://com.palm.power/timeout/", subscribe: true},
{name: "slider", kind: ekl.Layout.SlidingPane, flex: 1, dismissDistance: 100, onDismiss: "hideDetailPane", style:"background:#000", components: [
{name: "main", layoutKind: enyo.HFlexLayout, flex: 1, components: [
{
Expand Down Expand Up @@ -61,9 +62,13 @@ enyo.kind({
},

// called when app is opened or reopened
relaunchHandler: function() {
this.processLaunchParams(enyo.windowParams);
relaunchHandler: function() {
this.processLaunchParams(enyo.windowParams);
this.$.dashboard.setLayers([]); // empty the notifications

// Do not bring window to front when refreshing.
if (enyo.windowParams.action == "refresh")
return true;
},

windowActivated: function() {
Expand All @@ -77,6 +82,11 @@ enyo.kind({

// the window is closed
unloaded: function() {
enyo.log("Unloading");

// Must stop refresh alarm, otherwise it will continue to relaunch app.
AppUI.stopAutoRefresher();

this.$.dashboard.setLayers([]);
},

Expand Down Expand Up @@ -199,6 +209,13 @@ enyo.kind({
case 'relaunch':
// should have "from" param, we will parse in future
break;

case 'refresh':
AppUI.refresh();

// Schedule next refresh since alarms are one time only.
AppUI.startAutoRefresher();
break;
}
},

Expand Down Expand Up @@ -394,15 +411,22 @@ enyo.kind({
AppUI.addFunction("startAutoRefresher", function() {
if (App.Prefs.get('network-refreshinterval') > 0) {
enyo.log('Starting auto-refresher', App.Prefs.get('network-refreshinterval'));
App._refresher = setInterval(function() {
this.$.alarmService.call({"key": "refresh",
"in": "00:01:00",
"uri": "palm://com.palm.applicationManager/launch",
"params": {"id": SPAZ_DEFAULT_APPID, "params": {"action": "refresh"}}},
{"method": "set"})

/*App._refresher = setInterval(function() {
enyo.log("Auto-refreshing");
AppUI.refresh();
}, App.Prefs.get('network-refreshinterval'));
}, App.Prefs.get('network-refreshinterval'));*/
}
}, this);
AppUI.addFunction("stopAutoRefresher", function() {
enyo.log("Clearing auto-refresher");
clearInterval(App._refresher);
this.$.alarmService.call({"key": "refresh"}, {"method": "clear"});
//clearInterval(App._refresher);
}, this);
AppUI.addFunction("restartAutoRefresher", function() {
enyo.log("Restarting auto-refresher");
Expand Down

0 comments on commit 3786176

Please sign in to comment.