From: David ‘Bombe’ Roden Date: Wed, 16 Jan 2013 15:35:35 +0000 (+0100) Subject: Convert “new post reply found” into EventBus-based event. X-Git-Tag: 0.8.5^2~3^2~115 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=227e3e5aa520354a7744844f9345bf20920519e7;p=Sone.git Convert “new post reply found” 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 a6acb05..0a2c534 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -36,6 +36,7 @@ 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.NewPostFoundEvent; +import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent; import net.pterodactylus.sone.core.event.NewSoneFoundEvent; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Client; @@ -1140,7 +1141,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis knownReplies.add(reply.getId()); reply.setKnown(true); } else if (!knownReplies.contains(reply.getId())) { - coreListenerManager.fireNewReplyFound(reply); + eventBus.post(new NewPostReplyFoundEvent(reply)); } } replies.put(reply.getId(), reply); @@ -1683,7 +1684,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis replies.put(reply.getId(), reply); } synchronized (knownReplies) { - coreListenerManager.fireNewReplyFound(reply); + eventBus.post(new NewPostReplyFoundEvent(reply)); } sone.addReply(reply); touchConfiguration(); diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListener.java b/src/main/java/net/pterodactylus/sone/core/CoreListener.java index e641be3..854af8a 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 a new reply has been found. - * - * @param reply - * The new reply - */ - public void newReplyFound(PostReply reply); - - /** * Notifies a listener that the given Sone is now marked as known. * * @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 eb577f5..289be50 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.PostReply; + +/** + * Event that signals that a new {@link PostReply} was found. + * + * @author David ‘Bombe’ Roden + */ +public class NewPostReplyFoundEvent extends PostReplyEvent { + + /** + * Creates a new “new post found” event. + * + * @param postReply + * The post reply that was found + */ + public NewPostReplyFoundEvent(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 42fd355..7432e5f 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -38,6 +38,7 @@ import java.util.logging.Logger; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.core.CoreListener; 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.data.Album; import net.pterodactylus.sone.data.Image; @@ -814,15 +815,12 @@ public class WebInterface implements CoreListener { } } - // - // CORELISTENER METHODS - // - /** * {@inheritDoc} */ - @Override - public void newReplyFound(PostReply reply) { + @Subscribe + public void newReplyFound(NewPostReplyFoundEvent newPostReplyFoundEvent) { + PostReply reply = newPostReplyFoundEvent.postReply(); boolean isLocal = reply.getSone().isLocal(); if (isLocal) { localReplyNotification.add(reply); @@ -840,6 +838,10 @@ public class WebInterface implements CoreListener { } } + // + // CORELISTENER METHODS + // + /** * {@inheritDoc} */