fix see word count on source/author, step 1
[fanfix.git] / src / be / nikiroo / fanfix / reader / ui / GuiReaderGroup.java
index c96b02df266e0ef307a023600a6085dd2caa83ad..efacb1f5f66c74a2282eba79e4b0debddcc98f72 100644 (file)
@@ -7,11 +7,9 @@ import java.awt.event.MouseEvent;
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.management.RuntimeErrorException;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 
-import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.fanfix.reader.ui.GuiReaderBook.BookActionListener;
 import be.nikiroo.utils.ui.WrapLayout;
 
@@ -25,7 +23,7 @@ public class GuiReaderGroup extends JPanel {
        private BookActionListener action;
        private Color backgroundColor;
        private GuiReader reader;
-       private List<MetaData> stories;
+       private List<GuiReaderBookInfo> infos;
        private List<GuiReaderBook> books;
        private JPanel pane;
        private boolean words; // words or authors (secondary info on books)
@@ -79,7 +77,7 @@ public class GuiReaderGroup extends JPanel {
         */
        public void setActionListener(BookActionListener action) {
                this.action = action;
-               refreshBooks(stories, words);
+               refreshBooks(infos, words);
        }
 
        /**
@@ -90,8 +88,8 @@ public class GuiReaderGroup extends JPanel {
         * @param seeWordcount
         *            TRUE to see word counts, FALSE to see authors
         */
-       public void refreshBooks(List<MetaData> stories, boolean seeWordcount) {
-               this.stories = stories;
+       public void refreshBooks(List<GuiReaderBookInfo> infos, boolean seeWordcount) {
+               this.infos = infos;
                this.words = seeWordcount;
 
                books = new ArrayList<GuiReaderBook>();
@@ -99,10 +97,15 @@ public class GuiReaderGroup extends JPanel {
                pane.invalidate();
                pane.removeAll();
 
-               if (stories != null) {
-                       for (MetaData meta : stories) {
-                               GuiReaderBook book = new GuiReaderBook(reader, meta,
-                                               reader.isCached(meta.getLuid()), seeWordcount);
+               if (infos != null) {
+                       for (GuiReaderBookInfo info : infos) {
+                               boolean isCached = false;
+                               if (info.getMeta() != null) {
+                                       isCached = reader.isCached(info.getMeta().getLuid());
+                               }
+
+                               GuiReaderBook book = new GuiReaderBook(reader, info, isCached,
+                                               words);
                                if (backgroundColor != null) {
                                        book.setBackground(backgroundColor);
                                }