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.NewSoneFoundEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Client;
import net.pterodactylus.sone.data.Image;
}
sone.setKnown(!newSone);
if (newSone) {
- coreListenerManager.fireNewSoneFound(sone);
+ eventBus.post(new NewSoneFoundEvent(sone));
for (Sone localSone : getLocalSones()) {
if (localSone.getOptions().getBooleanOption("AutoFollow").get()) {
followSone(localSone, sone);
public interface CoreListener extends EventListener {
/**
- * Notifies a listener that a new Sone has been discovered.
- *
- * @param sone
- * The new Sone
- */
- public void newSoneFound(Sone sone);
-
- /**
* Notifies a listener that a new post has been found.
*
* @param post
//
/**
- * Notifies all listeners that a new Sone has been discovered.
- *
- * @see CoreListener#newSoneFound(Sone)
- * @param sone
- * The discovered sone
- */
- void fireNewSoneFound(Sone sone) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.newSoneFound(sone);
- }
- }
-
- /**
* Notifies all listeners that a new post has been found.
*
* @see CoreListener#newPostFound(Post)
--- /dev/null
+/*
+ * Sone - NewSoneFoundEvent.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 new remote Sone was found.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class NewSoneFoundEvent extends SoneEvent {
+
+ /**
+ * Creates a new “new Sone found” event.
+ *
+ * @param sone
+ * The Sone that was found
+ */
+ public NewSoneFoundEvent(Sone sone) {
+ super(sone);
+ }
+
+}
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.core.CoreListener;
+import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Post;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
+import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;
import freenet.clients.http.SessionManager;
}
//
- // CORELISTENER METHODS
+ // EVENT HANDLERS
//
/**
* {@inheritDoc}
*/
- @Override
- public void newSoneFound(Sone sone) {
- newSoneNotification.add(sone);
+ @Subscribe
+ public void newSoneFound(NewSoneFoundEvent newSoneFoundEvent) {
+ newSoneNotification.add(newSoneFoundEvent.sone());
if (!hasFirstStartNotification()) {
notificationManager.addNotification(newSoneNotification);
}
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/