From 455d843a2d2c785a317085e085d4265988b3c0da Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 16 Jan 2013 18:53:57 +0100 Subject: [PATCH] =?utf8?q?Convert=20=E2=80=9CSone=20removed=E2=80=9D=20int?= =?utf8?q?o=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/SoneRemovedEvent.java | 39 ++++++++++++++++++++++ .../net/pterodactylus/sone/web/WebInterface.java | 20 ++++++----- 5 files changed, 53 insertions(+), 30 deletions(-) create mode 100644 src/main/java/net/pterodactylus/sone/core/event/SoneRemovedEvent.java diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 0275e8a..c62a06f 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -41,6 +41,7 @@ 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; +import net.pterodactylus.sone.core.event.SoneRemovedEvent; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Client; import net.pterodactylus.sone.data.Image; @@ -2433,7 +2434,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis synchronized (sones) { sones.remove(identity.getId()); } - coreListenerManager.fireSoneRemoved(sone); + eventBus.post(new SoneRemovedEvent(sone)); } // diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListener.java b/src/main/java/net/pterodactylus/sone/core/CoreListener.java index f2ec67a..970d9e9 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 was removed. - * - * @param sone - * The removed Sone - */ - public void soneRemoved(Sone sone); - - /** * Notifies a listener that the given post was removed. * * @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 a88bef5..25f24c3 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 {@link Sone} was removed. + * + * @author David ‘Bombe’ Roden + */ +public class SoneRemovedEvent extends SoneEvent { + + /** + * Creates a new “Sone removed” event. + * + * @param sone + * The Sone that was removed + */ + public SoneRemovedEvent(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 b6d2d37..14bbcc4 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -43,6 +43,7 @@ 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; +import net.pterodactylus.sone.core.event.SoneRemovedEvent; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Post; @@ -887,18 +888,21 @@ public class WebInterface implements CoreListener { mentionNotification.remove(markPostReplyKnownEvent.postReply().getPost()); } - // - // CORELISTENER METHODS - // - /** - * {@inheritDoc} + * Notifies the web interface that a {@link Sone} was removed. + * + * @param soneRemovedEvent + * The event */ - @Override - public void soneRemoved(Sone sone) { - newSoneNotification.remove(sone); + @Subscribe + public void soneRemoved(SoneRemovedEvent soneRemovedEvent) { + newSoneNotification.remove(soneRemovedEvent.sone()); } + // + // CORELISTENER METHODS + // + /** * {@inheritDoc} */ -- 2.7.4