@@ -35,7 +35,8 @@ public class CacheManifestStatusIndicator implements EntryPoint {
3535 // TODO(manolo): should be configurable via offline connector
3636 private int updateCheckInterval = 1800000 ;
3737
38- private static final Logger logger = Logger .getLogger (CacheManifestStatusIndicator .class .getName ());
38+ private static final Logger logger = Logger
39+ .getLogger (CacheManifestStatusIndicator .class .getName ());
3940
4041 private static boolean confirmationRequired = true ;
4142
@@ -48,8 +49,8 @@ public void onModuleLoad() {
4849 }
4950
5051 /**
51- * Let the indicator ask the user to reload the application
52- * when a new version of the app has been downloaded.
52+ * Let the indicator ask the user to reload the application when a new
53+ * version of the app has been downloaded.
5354 */
5455 public static void setConfirmationRequired (boolean b ) {
5556 confirmationRequired = b ;
@@ -59,15 +60,15 @@ public static void setConfirmationRequired(boolean b) {
5960 * return true if we are downloading a new version of the app.
6061 */
6162 public static boolean isUpdating () {
62- return updating || getStatus () == CHECKING || getStatus () == DOWNLOADING ;
63+ return updating || getStatus () == CHECKING
64+ || getStatus () == DOWNLOADING ;
6365 }
6466
6567 /**
6668 * Initializes and starts the monitoring.
6769 */
6870 public void init () {
6971 loadSettingsFromLocalStorage ();
70- hookAllListeners (this );
7172 scheduleUpdateChecker ();
7273 if (getStatus () == CHECKING || getStatus () == DOWNLOADING ) {
7374 showProgress ();
@@ -79,8 +80,8 @@ public void init() {
7980
8081 private void pollForStatusOnAndroid () {
8182 if (BrowserInfo .get ().isAndroid ()) {
82- Scheduler .get (). scheduleFixedPeriod (
83- new Scheduler .RepeatingCommand () {
83+ Scheduler .get ()
84+ . scheduleFixedPeriod ( new Scheduler .RepeatingCommand () {
8485 @ Override
8586 public boolean execute () {
8687 if (updating ) {
@@ -121,7 +122,8 @@ private void loadSettingsFromLocalStorage() {
121122 && !updateCheckIntervalStr .isEmpty ()) {
122123 // The value in local storage is in seconds, but we need
123124 // milliseconds.
124- updateCheckInterval = Integer .valueOf (updateCheckIntervalStr ) * 1000 ;
125+ updateCheckInterval = Integer .valueOf (updateCheckIntervalStr )
126+ * 1000 ;
125127 }
126128 }
127129 }
@@ -135,9 +137,8 @@ private void scheduleUpdateChecker() {
135137 public boolean execute () {
136138 // Don't try to update cache if already updating or app is
137139 // paused
138- if (!isUpdating ()
139- && OfflineModeEntrypoint .get ().getNetworkStatus ()
140- .isAppRunning ()) {
140+ if (!isUpdating () && OfflineModeEntrypoint .get ()
141+ .getNetworkStatus ().isAppRunning ()) {
141142 updateCache ();
142143 }
143144 return true ;
@@ -210,7 +211,8 @@ protected void hideProgress() {
210211 * true to force reloading the site without asking the user.
211212 */
212213 private void requestUpdate () {
213- logger .info ("Application cache updated, confirmationRequired=" + confirmationRequired );
214+ logger .info ("Application cache updated, confirmationRequired="
215+ + confirmationRequired );
214216 if (!confirmationRequired || Window .confirm (updateNowMessage )) {
215217 Window .Location .reload ();
216218 }
@@ -219,48 +221,28 @@ private void requestUpdate() {
219221 /**
220222 * Hooks all listeners to the specified instance.
221223 *
224+ * @deprecated This is NOP as Safari, Chrome and Firefox do not need this
225+ * anymore.
226+ *
222227 * @param instance
223228 * the instance to hook the listeners to.
224229 */
230+ @ Deprecated
225231 protected final native void hookAllListeners (
226232 CacheManifestStatusIndicator instance )
227233 /*-{
228- $wnd.applicationCache.addEventListener('cached',
229- function(event) {
230- instance.@com.vaadin.addon.touchkit.gwt.client.offlinemode.CacheManifestStatusIndicator::onCacheEvent(Lcom/google/gwt/user/client/Event;)(event);
231- }, false);
232- $wnd.applicationCache.addEventListener('checking',
233- function(event) {
234- instance.@com.vaadin.addon.touchkit.gwt.client.offlinemode.CacheManifestStatusIndicator::onCacheEvent(Lcom/google/gwt/user/client/Event;)(event);
235- }, false);
236- $wnd.applicationCache.addEventListener('downloading',
237- function(event) {
238- instance.@com.vaadin.addon.touchkit.gwt.client.offlinemode.CacheManifestStatusIndicator::onCacheEvent(Lcom/google/gwt/user/client/Event;)(event);
239- }, false);
240- $wnd.applicationCache.addEventListener('noupdate',
241- function(event) {
242- instance.@com.vaadin.addon.touchkit.gwt.client.offlinemode.CacheManifestStatusIndicator::onCacheEvent(Lcom/google/gwt/user/client/Event;)(event);
243- }, false);
244- $wnd.applicationCache.addEventListener('updateready',
245- function(event) {
246- instance.@com.vaadin.addon.touchkit.gwt.client.offlinemode.CacheManifestStatusIndicator::onCacheEvent(Lcom/google/gwt/user/client/Event;)(event);
247- }, false);
248- $wnd.applicationCache.addEventListener('error',
249- function(event) {
250- instance.@com.vaadin.addon.touchkit.gwt.client.offlinemode.CacheManifestStatusIndicator::onError(Lcom/google/gwt/user/client/Event;)(event);
251- }, false);
252234 }-*/ ;
253235
254236 /**
255237 * @return The status of the application cache. See the constants in this
256- * class for possible values. Return 99 if application cache does
238+ * class for possible values. Return 99 if application cache does
257239 * not exist.
258240 */
259241 private static native int getStatus ()
260242 /*-{
261- if($wnd.applicationCache) {
243+ if($wnd.applicationCache) {
262244 return $wnd.applicationCache.status;
263- }
245+ }
264246 return 99;
265247 }-*/ ;
266248
0 commit comments