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;
public void unlockSone(Sone sone) {
synchronized (lockedSones) {
if (lockedSones.remove(sone)) {
- coreListenerManager.fireSoneUnlocked(sone);
+ eventBus.post(new SoneUnlockedEvent(sone));
}
}
}
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)
//
/**
- * Notifies all listeners that the given Sone was unlocked.
- *
- * @see CoreListener#soneUnlocked(Sone)
- * @param sone
- * The Sone that was unlocked
- */
- void fireSoneUnlocked(Sone sone) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.soneUnlocked(sone);
- }
- }
-
- /**
* Notifies all listeners that the insert of the given Sone has started.
*
* @see SoneInsertListener#insertStarted(Sone)
--- /dev/null
+/*
+ * Sone - SoneUnlockedEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+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 <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class SoneUnlockedEvent extends SoneEvent {
+
+ /**
+ * Creates a new “Sone unlocked” event.
+ *
+ * @param sone
+ * The Sone that was unlocked
+ */
+ public SoneUnlockedEvent(Sone sone) {
+ super(sone);
+ }
+
+}
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;
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}
*/