diff --git a/dashboard-ui/cordova/android/logging.js b/dashboard-ui/cordova/android/logging.js new file mode 100644 index 0000000000..112f5b8644 --- /dev/null +++ b/dashboard-ui/cordova/android/logging.js @@ -0,0 +1,6 @@ +window.Logger = { + + log: function (str) { + LoggingBridge.log(str); + } +}; \ No newline at end of file diff --git a/dashboard-ui/scripts/homenextup.js b/dashboard-ui/scripts/homenextup.js index c838429e73..90540f2d43 100644 --- a/dashboard-ui/scripts/homenextup.js +++ b/dashboard-ui/scripts/homenextup.js @@ -96,6 +96,8 @@ elem.innerHTML = html; ImageLoader.lazyChildren(elem); Dashboard.hideLoadingMsg(); + + LibraryBrowser.setLastRefreshed(page); }); } @@ -184,7 +186,7 @@ page.querySelector('#resumableItems').classList.remove('hiddenScrollX'); } - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { reload(page); } }); diff --git a/dashboard-ui/scripts/homeupcoming.js b/dashboard-ui/scripts/homeupcoming.js index 765f02a945..9b9bc1e444 100644 --- a/dashboard-ui/scripts/homeupcoming.js +++ b/dashboard-ui/scripts/homeupcoming.js @@ -55,6 +55,7 @@ Dashboard.hideLoadingMsg(); + LibraryBrowser.setLastRefreshed(page); }); } @@ -62,7 +63,7 @@ var page = this; - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { loadUpcoming(page); } }); diff --git a/dashboard-ui/scripts/indexpage.js b/dashboard-ui/scripts/indexpage.js index 0f751fe4af..c0892fe9a3 100644 --- a/dashboard-ui/scripts/indexpage.js +++ b/dashboard-ui/scripts/indexpage.js @@ -176,7 +176,7 @@ var page = this; - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { if (window.ApiClient) { var userId = Dashboard.getCurrentUserId(); @@ -192,6 +192,8 @@ showWelcomeIfNeeded(page, result); } Dashboard.hideLoadingMsg(); + + LibraryBrowser.setLastRefreshed(page); }); }); diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 8972b13377..3097522ea4 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -3,7 +3,7 @@ var pageSizeKey = 'pagesize_v4'; return { - getDefaultPageSize: function (key, defaultValue) { + getDefaultPageSize: function(key, defaultValue) { var saved = appStorage.getItem(key || pageSizeKey); @@ -21,13 +21,13 @@ return isChrome ? 200 : 100; }, - getDefaultItemsView: function (view, mobileView) { + getDefaultItemsView: function(view, mobileView) { return $.browser.mobile ? mobileView : view; }, - loadSavedQueryValues: function (key, query) { + loadSavedQueryValues: function(key, query) { var values = appStorage.getItem(key + '_' + Dashboard.getCurrentUserId()); @@ -41,7 +41,7 @@ return query; }, - saveQueryValues: function (key, query) { + saveQueryValues: function(key, query) { var values = {}; @@ -59,7 +59,7 @@ } }, - saveViewSetting: function (key, value) { + saveViewSetting: function(key, value) { try { appStorage.setItem(key + '_' + Dashboard.getCurrentUserId() + '_view', value); @@ -68,7 +68,7 @@ } }, - getSavedViewSetting: function (key) { + getSavedViewSetting: function(key) { var deferred = $.Deferred(); var val = appStorage.getItem(key + '_' + Dashboard.getCurrentUserId() + '_view'); @@ -77,6 +77,27 @@ return deferred.promise(); }, + needsRefresh: function(elem) { + + var last = elem.getAttribute('data-lastrefresh') || '0'; + + if (NavHelper.isBack()) { + return false; + } + + var now = new Date().getTime(); + if ((now - parseInt(last)) < 90000) { + return false; + } + + return true; + }, + + setLastRefreshed: function(elem) { + + elem.setAttribute('data-lastrefresh', new Date().getTime()); + }, + getDateParamValue: function (date) { function formatDigit(i) { diff --git a/dashboard-ui/scripts/librarymenu.js b/dashboard-ui/scripts/librarymenu.js index 750c063000..26c9f64282 100644 --- a/dashboard-ui/scripts/librarymenu.js +++ b/dashboard-ui/scripts/librarymenu.js @@ -699,28 +699,13 @@ } } - // The first time we create the view menu bar, wait until doc ready + login validated - // Otherwise we run into the jQM redirect back and forth problem - var updateViewMenuBarBeforePageShow = false; - $(document).on('pagebeforeshowready', ".page", function () { var page = this; requiresDashboardDrawerRefresh = true; - if (updateViewMenuBarBeforePageShow) { - onPageBeforeShowDocumentReady(page); - } - - }).one('pageshowready', ".page", function () { - - var page = this; - - $(function () { - onPageBeforeShowDocumentReady(page); - updateViewMenuBarBeforePageShow = true; - }); + onPageBeforeShowDocumentReady(page); }).on('pageshowready', ".page", function () { @@ -757,10 +742,7 @@ if (AppInfo.enableBottomTabs) { page.classList.add('noSecondaryNavPage'); - $(function () { - - document.querySelector('.footer').classList.add('footerOverBottomTabs'); - }); + document.querySelector('.footer').classList.add('footerOverBottomTabs'); } else { @@ -972,25 +954,7 @@ $.fn.createHoverTouch = function () { return backUrl == getWindowUrl(); } - function needsRefresh(elem) { - - var last = elem.getAttribute('data-lastrefresh') || '0'; - - if (isBack()) { - return false; - } - - var now = new Date().getTime(); - if ((now - parseInt(last)) < 60000) { - return false; - } - - elem.setAttribute('data-lastrefresh', now); - return true; - } - window.NavHelper = { - needsRefresh: needsRefresh, isBack: isBack }; diff --git a/dashboard-ui/scripts/livetvchannels.js b/dashboard-ui/scripts/livetvchannels.js index 648ba6d441..d4814ca626 100644 --- a/dashboard-ui/scripts/livetvchannels.js +++ b/dashboard-ui/scripts/livetvchannels.js @@ -65,6 +65,8 @@ renderChannels(page, result); hideLoadingMessage(page); + + LibraryBrowser.setLastRefreshed(page); }); } @@ -116,7 +118,7 @@ // Can't use pagebeforeshow here or the loading popup won't center correctly var page = this; - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { query.UserId = Dashboard.getCurrentUserId(); LibraryBrowser.loadSavedQueryValues('movies', query); reloadItems(page); diff --git a/dashboard-ui/scripts/livetvguide.js b/dashboard-ui/scripts/livetvguide.js index 070a0f6682..e04206867f 100644 --- a/dashboard-ui/scripts/livetvguide.js +++ b/dashboard-ui/scripts/livetvguide.js @@ -70,6 +70,8 @@ Dashboard.hideModalLoadingMsg(); + LibraryBrowser.setLastRefreshed(page); + }); var channelPagingHtml = LibraryBrowser.getQueryPagingHtml({ @@ -484,7 +486,7 @@ var page = this; - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { reloadPage(page); } }); diff --git a/dashboard-ui/scripts/livetvsuggested.js b/dashboard-ui/scripts/livetvsuggested.js index 5ef96fdf0e..500424a6bb 100644 --- a/dashboard-ui/scripts/livetvsuggested.js +++ b/dashboard-ui/scripts/livetvsuggested.js @@ -28,6 +28,8 @@ elem.innerHTML = html; ImageLoader.lazyChildren(elem); Dashboard.hideLoadingMsg(); + + LibraryBrowser.setLastRefreshed(page); }); } @@ -116,7 +118,7 @@ var page = this; - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { reload(page); } }); diff --git a/dashboard-ui/scripts/moviesrecommended.js b/dashboard-ui/scripts/moviesrecommended.js index 48572dddab..bf1066b4e5 100644 --- a/dashboard-ui/scripts/moviesrecommended.js +++ b/dashboard-ui/scripts/moviesrecommended.js @@ -249,7 +249,7 @@ $(containers).removeClass('hiddenScrollX'); } - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { loadResume(page, userId, parentId); loadLatest(page, userId, parentId); diff --git a/dashboard-ui/scripts/musicrecommended.js b/dashboard-ui/scripts/musicrecommended.js index 2a223a2a55..69beef1333 100644 --- a/dashboard-ui/scripts/musicrecommended.js +++ b/dashboard-ui/scripts/musicrecommended.js @@ -47,6 +47,8 @@ ImageLoader.lazyChildren(elem); Dashboard.hideLoadingMsg(); + + LibraryBrowser.setLastRefreshed(page); }); } @@ -192,7 +194,7 @@ $(containers).removeClass('hiddenScrollX'); } - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { loadLatest(page, parentId); loadPlaylists(page, parentId); loadRecentlyPlayed(page, parentId); diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 86307f7503..89268335bf 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -2016,6 +2016,10 @@ var AppInfo = {}; if (Dashboard.isConnectMode()) { + if (AppInfo.isNativeApp && $.browser.android) { + require(['cordova/android/logging']); + } + require(['appstorage'], function () { capabilities.DeviceProfile = MediaPlayer.getDeviceProfile(Math.max(screen.height, screen.width)); diff --git a/dashboard-ui/scripts/tvlatest.js b/dashboard-ui/scripts/tvlatest.js index 3429060728..6fa5e9c405 100644 --- a/dashboard-ui/scripts/tvlatest.js +++ b/dashboard-ui/scripts/tvlatest.js @@ -7,6 +7,8 @@ function loadLatest(page) { + Dashboard.showLoadingMsg(); + var userId = Dashboard.getCurrentUserId(); var parentId = LibraryMenu.getTopParentId(); @@ -68,13 +70,16 @@ var elem = page.querySelector('#latestEpisodes'); elem.innerHTML = html; ImageLoader.lazyChildren(elem); + + Dashboard.hideLoadingMsg(); + LibraryBrowser.setLastRefreshed(page); }); } $(document).on('pagebeforeshowready', "#tvNextUpPage", function () { var page = this; - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { loadLatest(page); } }); diff --git a/dashboard-ui/scripts/tvrecommended.js b/dashboard-ui/scripts/tvrecommended.js index 07575c7717..36de7626da 100644 --- a/dashboard-ui/scripts/tvrecommended.js +++ b/dashboard-ui/scripts/tvrecommended.js @@ -92,6 +92,8 @@ elem.innerHTML = html; ImageLoader.lazyChildren(elem); Dashboard.hideLoadingMsg(); + + LibraryBrowser.setLastRefreshed(page); }); } @@ -180,7 +182,7 @@ page.querySelector('#resumableItems').classList.remove('hiddenScrollX'); } - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { reload(page); } }); diff --git a/dashboard-ui/scripts/tvupcoming.js b/dashboard-ui/scripts/tvupcoming.js index 386d4e48f2..72c20f0ee7 100644 --- a/dashboard-ui/scripts/tvupcoming.js +++ b/dashboard-ui/scripts/tvupcoming.js @@ -56,13 +56,15 @@ Dashboard.hideLoadingMsg(); + LibraryBrowser.setLastRefreshed(page); + }); } $(document).on('pagebeforeshowready', "#tvUpcomingPage", function () { var page = this; - if (NavHelper.needsRefresh(page)) { + if (LibraryBrowser.needsRefresh(page)) { loadUpcoming(page); } });