import static com.google.common.base.Preconditions.*;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import net.pterodactylus.rhynodge.Reaction;
/** The new comics. */
private final List<Comic> newComics = Lists.newArrayList();
+ /** The latest comic state. */
+ private ComicState mergedComicState;
+
@Override
public State mergeStates(State previousState, State currentState) {
checkArgument(previousState instanceof ComicState, "previous state must be a comic state");
ComicState currentComicState = (ComicState) currentState;
/* copy old state into new state. */
- ComicState mergedComicState = new ComicState();
+ mergedComicState = new ComicState();
for (Comic comic : previousComicState) {
mergedComicState.add(comic);
}
generateComicHtml(html, newComic);
}
+ List<Comic> latestComics = new ArrayList<Comic>(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("</body>").toString();
}
html.append("\" alt=\"").append(StringEscapeUtils.escapeHtml4(strip.comment()));
html.append("\" title=\"").append(StringEscapeUtils.escapeHtml4(strip.comment()));
html.append("\"></div>\n");
+ html.append("<div>").append(StringEscapeUtils.escapeHtml4(strip.comment())).append("</div>\n");
}
}