From 45bec66b94d51f9f6f896fe3705274c7890a2ed6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 16 Jan 2013 16:43:55 +0100 Subject: [PATCH] =?utf8?q?Convert=20=E2=80=9CSone=20marked=20as=20known?= =?utf8?q?=E2=80=9D=20into=20EventBus-based=20event.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/core/Core.java | 3 +- .../net/pterodactylus/sone/core/CoreListener.java | 8 ----- .../sone/core/CoreListenerManager.java | 13 ------- .../sone/core/event/MarkSoneKnownEvent.java | 40 ++++++++++++++++++++++ .../net/pterodactylus/sone/web/WebInterface.java | 15 ++++---- 5 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 src/main/java/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.java diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 0a2c534..ab6623b 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -35,6 +35,7 @@ import java.util.logging.Logger; import net.pterodactylus.sone.core.Options.DefaultOption; import net.pterodactylus.sone.core.Options.Option; import net.pterodactylus.sone.core.Options.OptionWatcher; +import net.pterodactylus.sone.core.event.MarkSoneKnownEvent; import net.pterodactylus.sone.core.event.NewPostFoundEvent; import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent; import net.pterodactylus.sone.core.event.NewSoneFoundEvent; @@ -1243,7 +1244,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis synchronized (knownSones) { knownSones.add(sone.getId()); } - coreListenerManager.fireMarkSoneKnown(sone); + eventBus.post(new MarkSoneKnownEvent(sone)); touchConfiguration(); } } diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListener.java b/src/main/java/net/pterodactylus/sone/core/CoreListener.java index 854af8a..fea874b 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListener.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListener.java @@ -34,14 +34,6 @@ import net.pterodactylus.util.version.Version; public interface CoreListener extends EventListener { /** - * Notifies a listener that the given Sone is now marked as known. - * - * @param sone - * The known Sone - */ - public void markSoneKnown(Sone sone); - - /** * Notifies a listener that the given post is now marked as known. * * @param post diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java index 289be50..6340b08 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java @@ -46,19 +46,6 @@ public class CoreListenerManager extends AbstractListenerManager. + */ + +package net.pterodactylus.sone.core.event; + +import net.pterodactylus.sone.data.Sone; + +/** + * Event that signals that a {@line Sone} has been marked as + * {@link Sone#isKnown() known}. + * + * @author David ‘Bombe’ Roden + */ +public class MarkSoneKnownEvent extends SoneEvent { + + /** + * Creates a new “Sone marked known” event. + * + * @param sone + * The Sone that was marked as known + */ + public MarkSoneKnownEvent(Sone sone) { + super(sone); + } + +} diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 7432e5f..224dc69 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -37,6 +37,7 @@ import java.util.logging.Logger; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.core.CoreListener; +import net.pterodactylus.sone.core.event.MarkSoneKnownEvent; import net.pterodactylus.sone.core.event.NewPostFoundEvent; import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent; import net.pterodactylus.sone.core.event.NewSoneFoundEvent; @@ -838,18 +839,18 @@ public class WebInterface implements CoreListener { } } - // - // CORELISTENER METHODS - // - /** * {@inheritDoc} */ - @Override - public void markSoneKnown(Sone sone) { - newSoneNotification.remove(sone); + @Subscribe + public void markSoneKnown(MarkSoneKnownEvent markSoneKnownEvent) { + newSoneNotification.remove(markSoneKnownEvent.sone()); } + // + // CORELISTENER METHODS + // + /** * {@inheritDoc} */ -- 2.7.4