コード例 #1
0
 private void restart() {
   if (!isStarted) return;
   if (theSubscription != null) {
     theSubscription.unsubscribe();
     theSubscription = null;
   }
   start();
   theWatchListeners.forEach(r -> r.run());
 }
コード例 #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<>();
 }
コード例 #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();
       });
 }