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;
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);
replies.put(reply.getId(), reply);
}
synchronized (knownReplies) {
- coreListenerManager.fireNewReplyFound(reply);
+ eventBus.post(new NewPostReplyFoundEvent(reply));
}
sone.addReply(reply);
touchConfiguration();
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
//
/**
- * Notifies all listeners that a new reply has been found.
- *
- * @see CoreListener#newReplyFound(PostReply)
- * @param reply
- * The new reply
- */
- void fireNewReplyFound(PostReply reply) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.newReplyFound(reply);
- }
- }
-
- /**
* Notifies all listeners that the given Sone is now marked as known.
*
* @see CoreListener#markSoneKnown(Sone)
--- /dev/null
+/*
+ * Sone - NewPostFoundEvent.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.PostReply;
+
+/**
+ * Event that signals that a new {@link PostReply} was found.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+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);
+ }
+
+}
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;
}
}
- //
- // 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);
}
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/