Exemplo n.º 1
0
 private void restart() {
   if (!isStarted) return;
   if (theSubscription != null) {
     theSubscription.unsubscribe();
     theSubscription = null;
   }
   start();
   theWatchListeners.forEach(r -> r.run());
 }
Exemplo n.º 2
0
 /** @param style The style to listen to */
 public StyleChangeObservable(QuickStyle style) {
   theStyle = style;
   theDomains = new ConcurrentHashSet<>();
   theAttributes = new LinkedHashSet<>();
   theStyleListeners = new ListenerSet<>();
   theStyleListeners.setUsedListener(
       used -> {
         if (used) {
           if (!theDomains.isEmpty() || !theAttributes.isEmpty() && isStarted) start();
         } else if (theSubscription != null) {
           theSubscription.unsubscribe();
           theSubscription = null;
         }
       });
   theWatchListeners = new ListenerSet<>();
 }
Exemplo n.º 3
0
 /**
  * @param style The style to listen to
  * @param other Another {@link StyleChangeObservable}. This observable will listen to the same
  *     attributes as this other observable.
  */
 public StyleChangeObservable(QuickStyle style, StyleChangeObservable other) {
   theStyle = style;
   theDomains = other.theDomains;
   theAttributes = other.theAttributes;
   theStyleListeners = new ListenerSet<>();
   theStyleListeners.setUsedListener(
       used -> {
         if (used) {
           if (!theDomains.isEmpty() || !theAttributes.isEmpty() && isStarted) start();
         } else if (theSubscription != null) {
           theSubscription.unsubscribe();
           theSubscription = null;
         }
       });
   theWatchListeners = new ListenerSet<>();
   other.theWatchListeners.add(
       () -> {
         restart();
       });
 }