From 5bec5f7d5b4fcbf25ff7fcc5636603611a9cc47f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 16 Jan 2013 17:13:24 +0100 Subject: [PATCH] =?utf8?q?Convert=20=E2=80=9Cpost=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 | 12 ------- .../sone/core/event/MarkPostKnownEvent.java | 40 ++++++++++++++++++++++ .../net/pterodactylus/sone/web/WebInterface.java | 19 +++++----- 5 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 src/main/java/net/pterodactylus/sone/core/event/MarkPostKnownEvent.java diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index ab6623b..0d7acf5 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.MarkPostKnownEvent; import net.pterodactylus.sone.core.event.MarkSoneKnownEvent; import net.pterodactylus.sone.core.event.NewPostFoundEvent; import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent; @@ -1592,7 +1593,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis public void markPostKnown(Post post) { post.setKnown(true); synchronized (knownPosts) { - coreListenerManager.fireMarkPostKnown(post); + eventBus.post(new MarkPostKnownEvent(post)); if (knownPosts.add(post.getId())) { touchConfiguration(); } diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListener.java b/src/main/java/net/pterodactylus/sone/core/CoreListener.java index fea874b..987a2c7 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 post is now marked as known. - * - * @param post - * The known post - */ - public void markPostKnown(Post post); - - /** * Notifies a listener that the given reply is now marked as known. * * @param reply diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java index 6340b08..ed3a6f0 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java @@ -46,18 +46,6 @@ public class CoreListenerManager extends AbstractListenerManager. + */ + +package net.pterodactylus.sone.core.event; + +import net.pterodactylus.sone.data.Post; + +/** + * Event that signals that a {@line Post} has been marked as + * {@link Post#isKnown() known}. + * + * @author David ‘Bombe’ Roden + */ +public class MarkPostKnownEvent extends PostEvent { + + /** + * Creates a new “post marked known” event. + * + * @param post + * The post that was marked as known + */ + public MarkPostKnownEvent(Post post) { + super(post); + } + +} diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 224dc69..74f9087 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.MarkPostKnownEvent; import net.pterodactylus.sone.core.event.MarkSoneKnownEvent; import net.pterodactylus.sone.core.event.NewPostFoundEvent; import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent; @@ -847,20 +848,20 @@ public class WebInterface implements CoreListener { newSoneNotification.remove(markSoneKnownEvent.sone()); } - // - // CORELISTENER METHODS - // - /** * {@inheritDoc} */ - @Override - public void markPostKnown(Post post) { - newPostNotification.remove(post); - localPostNotification.remove(post); - mentionNotification.remove(post); + @Subscribe + public void markPostKnown(MarkPostKnownEvent markPostKnownEvent) { + newPostNotification.remove(markPostKnownEvent.post()); + localPostNotification.remove(markPostKnownEvent.post()); + mentionNotification.remove(markPostKnownEvent.post()); } + // + // CORELISTENER METHODS + // + /** * {@inheritDoc} */ -- 2.7.4