From: David ‘Bombe’ Roden Date: Wed, 16 Jan 2013 18:10:27 +0000 (+0100) Subject: Convert “Sone unlocked” into EventBus-based event. X-Git-Tag: 0.8.5^2~3^2~104 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ba4c1d2a5995657d48dce310ea854fa1f164a481;p=Sone.git Convert “Sone unlocked” 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 ed8cc72..07db844 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -45,6 +45,7 @@ import net.pterodactylus.sone.core.event.PostRemovedEvent; import net.pterodactylus.sone.core.event.PostReplyRemovedEvent; import net.pterodactylus.sone.core.event.SoneLockedEvent; import net.pterodactylus.sone.core.event.SoneRemovedEvent; +import net.pterodactylus.sone.core.event.SoneUnlockedEvent; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Client; import net.pterodactylus.sone.data.Image; @@ -814,7 +815,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis public void unlockSone(Sone sone) { synchronized (lockedSones) { if (lockedSones.remove(sone)) { - coreListenerManager.fireSoneUnlocked(sone); + eventBus.post(new SoneUnlockedEvent(sone)); } } } diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListener.java b/src/main/java/net/pterodactylus/sone/core/CoreListener.java index a826e64..aa6996f 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListener.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListener.java @@ -32,14 +32,6 @@ import net.pterodactylus.util.version.Version; public interface CoreListener extends EventListener { /** - * Notifies a listener that a Sone was unlocked. - * - * @param sone - * The Sone that was unlocked - */ - public void soneUnlocked(Sone sone); - - /** * Notifies a listener that the insert of the given Sone has started. * * @see SoneInsertListener#insertStarted(Sone) diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java index 44fb67b..d485b12 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java @@ -44,19 +44,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 unlocked. Only + * {@link Sone#isLocal() local Sones} can be locked. + * + * @author David ‘Bombe’ Roden + */ +public class SoneUnlockedEvent extends SoneEvent { + + /** + * Creates a new “Sone unlocked” event. + * + * @param sone + * The Sone that was unlocked + */ + public SoneUnlockedEvent(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 9e5e0eb..96b42b0 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -47,6 +47,7 @@ import net.pterodactylus.sone.core.event.PostRemovedEvent; import net.pterodactylus.sone.core.event.PostReplyRemovedEvent; import net.pterodactylus.sone.core.event.SoneLockedEvent; import net.pterodactylus.sone.core.event.SoneRemovedEvent; +import net.pterodactylus.sone.core.event.SoneUnlockedEvent; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Post; @@ -959,19 +960,22 @@ public class WebInterface implements CoreListener { lockedSonesTickerObjects.put(sone, tickerObject); } - // - // CORELISTENER METHODS - // - /** - * {@inheritDoc} + * Notifies the web interface that a Sone was unlocked. + * + * @param soneUnlockedEvent + * The event */ - @Override - public void soneUnlocked(Sone sone) { - lockedSonesNotification.remove(sone); - Ticker.getInstance().deregisterEvent(lockedSonesTickerObjects.remove(sone)); + @Subscribe + public void soneUnlocked(SoneUnlockedEvent soneUnlockedEvent) { + lockedSonesNotification.remove(soneUnlockedEvent.sone()); + Ticker.getInstance().deregisterEvent(lockedSonesTickerObjects.remove(soneUnlockedEvent.sone())); } + // + // CORELISTENER METHODS + // + /** * {@inheritDoc} */