diff options
| author | ARC <arjunrc@gmail.com> | 2015-05-02 16:36:34 -0400 |
|---|---|---|
| committer | ARC <arjunrc@gmail.com> | 2015-05-02 16:36:34 -0400 |
| commit | 3eb690e300d797433455c1fcbd9a769c15aa9d7c (patch) | |
| tree | f366512aedac1bba31bf22e440edf49e7003bcf3 /www/js/MontageCtrl.js | |
| parent | 9faf95be527b8b7c23e4ed4226c35bb771129f41 (diff) | |
Android Users Rejoice! Major updates: Android port works like a charm now. Integrated Crosswalk for good performance for Android phones, reworked Montage view to step around Chrome's problem of getting stuck in pending state for HTTP requests that don't close soon and more.
Diffstat (limited to 'www/js/MontageCtrl.js')
| -rw-r--r-- | www/js/MontageCtrl.js | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 698c586b..57573c5e 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -1,12 +1,54 @@ // Controller for the montage view -angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', function ($scope, $rootScope, ZMDataModel, message,$ionicSideMenuDelegate) { +angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', function ($scope, $rootScope, ZMDataModel, message,$ionicSideMenuDelegate, $timeout, $interval) { + var timestamp = new Date().getUTCMilliseconds(); + + +// In Android, the app runs full steam while in background mode +// while in iOS it gets suspended unless you ask for specific resources +// So while this view, we DON'T want Android to keep sending 1 second +// refreshes to the server for images we are not seeing! + +function onPause() { + console.log ("*** Moving to Background ***"); // Handle the pause event + console.log ("*** CANCELLING INTERVAL ****"); + $interval.cancel(intervalHandle); +} + + document.addEventListener("pause", onPause, false); + + // I was facing a lot of problems with Chrome/crosswalk getting stuck with + // pending HTTP requests after a while. There is a problem with chrome handling + // multiple streams of always open HTTP get's (image streaming). This problem + // does not arise when the image is streamed for a single monitor - just multiple + + // To work around this I am taking a single snapshot of ZMS and have implemented a timer + // to reload the snapshot every 1 second. Seems to work reliably even thought its a higer + // load. Will it bonk with many monitors? Who knows. I have tried with 5 and 1280x960@32bpp + + + this.loadNotifications = function (){ + // randomval is appended to img src, so after each interval the image reloads + $scope.randomval = (new Date()).getTime(); + //console.log ("**** NOTIFICATION with rand="+$scope.randomval+"*****"); + }; + + var intervalHandle = $interval(function(){ + this.loadNotifications(); + }.bind(this), 1000); + + this.loadNotifications(); $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); } + $scope.$on('$destroy', function () { + console.log ("*** CANCELLING INTERVAL ****"); + $interval.cancel(intervalHandle); + }); + $scope.$on('$ionicView.loaded', function(){ console.log("**VIEW ** Montage Ctrl Loaded"); @@ -25,19 +67,12 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', function ($s }); - - $scope.getMontageImagePath = function () - { - return ZMDataModel.getMontageImagePath(); - } - $scope.isSimulated = function () { return ZMDataModel.isSimulated(); } - //var monsize =3; console.log("********* Inside Montage Ctrl"); $scope.LoginData = ZMDataModel.getLogin(); @@ -50,11 +85,12 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', function ($s $scope.$on('$ionicView.afterEnter', function () { // This rand is really used to reload the monitor image in img-src so it is not cached // I am making sure the image in montage view is always fresh + // I don't think I am using this anymore FIXME: check and delete if needed $rootScope.rand = Math.floor((Math.random() * 100000) + 1); - console.log("Rootscoxxpe Montage is " + ZMDataModel.getMontageSize() + " and slider montage is " + $scope.slider.monsize); }); - + // we are monitoring the slider for movement here + // make sure this is an object - so its passed by reference from the template to the controller! $scope.$watch('slider.monsize', function () { console.log('Slider has changed'); ZMDataModel.setMontageSize($scope.slider.monsize); |
