From 74bbe79111f63cda9baca99d8122a73c335ecfe1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 1 Mar 2013 07:22:01 +0100 Subject: [PATCH] Show the latest seven non-new comics below the most recent one. --- .../pterodactylus/rhynodge/triggers/NewComicTrigger.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java b/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java index fa3347c..0f89ddb 100644 --- a/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java +++ b/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java @@ -19,6 +19,8 @@ package net.pterodactylus.rhynodge.triggers; import static com.google.common.base.Preconditions.*; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import net.pterodactylus.rhynodge.Reaction; @@ -127,6 +129,19 @@ public class NewComicTrigger implements Trigger { generateComicHtml(html, newComic); } + List latestComics = new ArrayList(mergedComicState.comics()); + Collections.reverse(latestComics); + int comicCount = 0; + for (Comic comic : latestComics) { + if (newComics.contains(comic)) { + continue; + } + generateComicHtml(html, comic); + if (++comicCount == 7) { + break; + } + } + return html.append("").toString(); } -- 2.7.4