diff options
author | Artur Signell <artur@vaadin.com> | 2013-04-04 12:08:38 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-04-04 12:08:38 +0300 |
commit | 74703a72ad1f954cdab11963054020175550362f (patch) | |
tree | 6ae71aac11fd2b711aff15741b5b222f48e9d670 | |
parent | e97d8f42b64ab091b6bf1c4a1a5b130c3c29e26a (diff) | |
download | vaadin-framework-74703a72ad1f954cdab11963054020175550362f.tar.gz vaadin-framework-74703a72ad1f954cdab11963054020175550362f.zip |
Fixed issue with IE8 showing loading indicator when it should not (#7448)
Change-Id: I07fd3f3051d3114e419a3a75a7a102c6ea52ab53
-rw-r--r-- | client/src/com/vaadin/client/VLoadingIndicator.java | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/VLoadingIndicator.java b/client/src/com/vaadin/client/VLoadingIndicator.java index ca29d6a042..d85ee7eaa0 100644 --- a/client/src/com/vaadin/client/VLoadingIndicator.java +++ b/client/src/com/vaadin/client/VLoadingIndicator.java @@ -26,21 +26,72 @@ public class VLoadingIndicator { private int delayStateDelay = 1500; private int waitStateDelay = 5000; - private Timer initialTimer = new Timer() { + /** + * Timer with method for checking if it has been cancelled. This class is a + * workaround for a IE8 problem which causes a timer to be fired even if it + * has been cancelled. + * + * @author Vaadin Ltd + * @since 7.1 + */ + private abstract static class LoadingIndicatorTimer extends Timer { + private boolean cancelled = false; + + @Override + public void cancel() { + super.cancel(); + cancelled = true; + } + + @Override + public void schedule(int delayMillis) { + super.schedule(delayMillis); + cancelled = false; + } + + @Override + public void scheduleRepeating(int periodMillis) { + super.scheduleRepeating(periodMillis); + cancelled = false; + } + + /** + * Checks if this timer has been cancelled. + * + * @return true if the timer has been cancelled, false otherwise + */ + public boolean isCancelled() { + return cancelled; + } + } + + private Timer initialTimer = new LoadingIndicatorTimer() { @Override public void run() { + if (isCancelled()) { + // IE8 does not properly cancel the timer in all cases. + return; + } show(); } }; - private Timer delayStateTimer = new Timer() { + private Timer delayStateTimer = new LoadingIndicatorTimer() { @Override public void run() { + if (isCancelled()) { + // IE8 does not properly cancel the timer in all cases. + return; + } getElement().setClassName(PRIMARY_STYLE_NAME + "-delay"); } }; - private Timer waitStateTimer = new Timer() { + private Timer waitStateTimer = new LoadingIndicatorTimer() { @Override public void run() { + if (isCancelled()) { + // IE8 does not properly cancel the timer in all cases. + return; + } getElement().setClassName(PRIMARY_STYLE_NAME + "-wait"); } }; |