From: David ‘Bombe’ Roden Date: Wed, 16 Jan 2013 18:02:53 +0000 (+0100) Subject: Convert “post reply removed” into EventBus-based event. X-Git-Tag: 0.8.5^2~3^2~106 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fdcd6fa4e0110028080d0b4a9ef3c5f8e5a5e867;p=Sone.git Convert “post reply removed” into EventBus-based event. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 81e5e09..e42a055 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -42,6 +42,7 @@ 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.PostRemovedEvent; +import net.pterodactylus.sone.core.event.PostReplyRemovedEvent; import net.pterodactylus.sone.core.event.SoneRemovedEvent; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Client; @@ -1133,7 +1134,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis for (PostReply reply : storedSone.getReplies()) { replies.remove(reply.getId()); if (!sone.getReplies().contains(reply)) { - coreListenerManager.fireReplyRemoved(reply); + eventBus.post(new PostReplyRemovedEvent(reply)); } } } @@ -2428,7 +2429,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis synchronized (knownReplies) { for (PostReply reply : sone.getReplies()) { replies.remove(reply.getId()); - coreListenerManager.fireReplyRemoved(reply); + eventBus.post(new PostReplyRemovedEvent(reply)); } } } diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListener.java b/src/main/java/net/pterodactylus/sone/core/CoreListener.java index 937ffb6..0ae6fe1 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListener.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListener.java @@ -20,7 +20,6 @@ package net.pterodactylus.sone.core; import java.util.EventListener; import net.pterodactylus.sone.data.Image; -import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.util.version.Version; @@ -33,14 +32,6 @@ import net.pterodactylus.util.version.Version; public interface CoreListener extends EventListener { /** - * Notifies a listener that the given reply was removed. - * - * @param reply - * The removed reply - */ - public void replyRemoved(PostReply reply); - - /** * Notifies a listener when a Sone was locked. * * @param sone diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java index a0c6d22..031fdb3 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java @@ -18,7 +18,6 @@ package net.pterodactylus.sone.core; import net.pterodactylus.sone.data.Image; -import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.util.event.AbstractListenerManager; import net.pterodactylus.util.version.Version; @@ -45,19 +44,6 @@ public class CoreListenerManager extends AbstractListenerManager. + */ + +package net.pterodactylus.sone.core.event; + +import net.pterodactylus.sone.data.PostReply; + +/** + * Event that signals that a {@link PostReply} was removed. + * + * @author David ‘Bombe’ Roden + */ +public class PostReplyRemovedEvent extends PostReplyEvent { + + /** + * Creates a new “post reply removed” event. + * + * @param postReply + * The post reply that was removed + */ + public PostReplyRemovedEvent(PostReply postReply) { + super(postReply); + } + +} diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 53f7dd9..4534c35 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -44,6 +44,7 @@ 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.PostRemovedEvent; +import net.pterodactylus.sone.core.event.PostReplyRemovedEvent; import net.pterodactylus.sone.core.event.SoneRemovedEvent; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Image; @@ -913,15 +914,15 @@ public class WebInterface implements CoreListener { mentionNotification.remove(postRemovedEvent.post()); } - // - // CORELISTENER METHODS - // - /** - * {@inheritDoc} + * Notifies the web interface that a {@link PostReply} was removed. + * + * @param postReplyRemovedEvent + * The event */ - @Override - public void replyRemoved(PostReply reply) { + @Subscribe + public void replyRemoved(PostReplyRemovedEvent postReplyRemovedEvent) { + PostReply reply = postReplyRemovedEvent.postReply(); newReplyNotification.remove(reply); localReplyNotification.remove(reply); if (!getMentionedSones(reply.getText()).isEmpty()) { @@ -935,6 +936,10 @@ public class WebInterface implements CoreListener { } } + // + // CORELISTENER METHODS + // + /** * {@inheritDoc} */