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.SoneLockedEvent;
import net.pterodactylus.sone.core.event.SoneRemovedEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Client;
public void lockSone(Sone sone) {
synchronized (lockedSones) {
if (lockedSones.add(sone)) {
- coreListenerManager.fireSoneLocked(sone);
+ eventBus.post(new SoneLockedEvent(sone));
}
}
}
public interface CoreListener extends EventListener {
/**
- * Notifies a listener when a Sone was locked.
- *
- * @param sone
- * The Sone that was locked
- */
- public void soneLocked(Sone sone);
-
- /**
* Notifies a listener that a Sone was unlocked.
*
* @param sone
//
/**
- * Notifies all listeners that the given Sone was locked.
- *
- * @see CoreListener#soneLocked(Sone)
- * @param sone
- * The Sone that was locked
- */
- void fireSoneLocked(Sone sone) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.soneLocked(sone);
- }
- }
-
- /**
* Notifies all listeners that the given Sone was unlocked.
*
* @see CoreListener#soneUnlocked(Sone)
--- /dev/null
+/*
+ * Sone - SoneLockedEvent.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 locked. Only
+ * {@link Sone#isLocal() local Sones} can be locked.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class SoneLockedEvent extends SoneEvent {
+
+ /**
+ * Creates a new “Sone locked” event.
+ *
+ * @param sone
+ * The Sone that was locked
+ */
+ public SoneLockedEvent(Sone sone) {
+ super(sone);
+ }
+
+}
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.SoneLockedEvent;
import net.pterodactylus.sone.core.event.SoneRemovedEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
}
}
- //
- // CORELISTENER METHODS
- //
-
/**
- * {@inheritDoc}
+ * Notifies the web interface that a Sone was locked.
+ *
+ * @param soneLockedEvent
+ * The event
*/
- @Override
- public void soneLocked(final Sone sone) {
+ @Subscribe
+ public void soneLocked(SoneLockedEvent soneLockedEvent) {
+ final Sone sone = soneLockedEvent.sone();
Object tickerObject = Ticker.getInstance().registerEvent(System.currentTimeMillis() + (5 * 60) * 1000, new Runnable() {
@Override
lockedSonesTickerObjects.put(sone, tickerObject);
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/