Add more warnings source to 1.6) and fix warnings
[nikiroo-utils.git] / src / be / nikiroo / fanfix / reader / TuiReaderStoryWindow.java
index 7eb592fd4686666a6237d4787243e2dd55ab1711..e8dafc3fa339b47f47f5c2cfb2df5e6d1fdace87 100644 (file)
@@ -12,26 +12,27 @@ import jexer.TLabel;
 import jexer.TText;
 import jexer.TWindow;
 import jexer.event.TResizeEvent;
-import be.nikiroo.fanfix.Instance;
 import be.nikiroo.fanfix.data.Chapter;
 import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.fanfix.data.Paragraph;
 import be.nikiroo.fanfix.data.Story;
+import be.nikiroo.fanfix.library.BasicLibrary;
 
-public class TuiReaderStoryWindow extends TWindow {
+class TuiReaderStoryWindow extends TWindow {
+       private BasicLibrary lib;
        private MetaData meta;
        private Story story;
        private TText textField;
-       private int chapter = -2;
+       private int chapter = -1;
        private List<TButton> navigationButtons;
        private TLabel chapterName;
 
-       public TuiReaderStoryWindow(TApplication app, MetaData meta) {
-               this(app, meta, 0);
-       }
-
-       public TuiReaderStoryWindow(TApplication app, MetaData meta, int chapter) {
+       // chapter: -1 for "none" (0 is desc)
+       public TuiReaderStoryWindow(TApplication app, BasicLibrary lib,
+                       MetaData meta, int chapter) {
                super(app, desc(meta), 0, 0, 60, 18, CENTERED | RESIZABLE);
+
+               this.lib = lib;
                this.meta = meta;
 
                // TODO: show all meta info before?
@@ -46,28 +47,35 @@ public class TuiReaderStoryWindow extends TWindow {
                // -3 because 0-based and 2 for borders
                int row = getHeight() - 3;
 
-               navigationButtons.add(addButton(" ", 0, row, null)); // for bg colour when << button is pressed
+               navigationButtons.add(addButton(" ", 0, row, null)); // for bg colour
+                                                                                                                               // when <<
+                                                                                                                               // button is
+                                                                                                                               // pressed
                navigationButtons.add(addButton("<<  ", 0, row, new TAction() {
+                       @Override
                        public void DO() {
                                setChapter(0);
                        }
                }));
                navigationButtons.add(addButton("<  ", 4, row, new TAction() {
+                       @Override
                        public void DO() {
                                setChapter(TuiReaderStoryWindow.this.chapter - 1);
                        }
                }));
                navigationButtons.add(addButton(">  ", 7, row, new TAction() {
+                       @Override
                        public void DO() {
                                setChapter(TuiReaderStoryWindow.this.chapter + 1);
                        }
                }));
                navigationButtons.add(addButton(">>  ", 10, row, new TAction() {
+                       @Override
                        public void DO() {
                                setChapter(getStory().getChapters().size());
                        }
                }));
-               
+
                navigationButtons.get(0).setEnabled(false);
                navigationButtons.get(1).setEnabled(false);
                navigationButtons.get(2).setEnabled(false);
@@ -113,14 +121,14 @@ public class TuiReaderStoryWindow extends TWindow {
 
                if (chapter != this.chapter) {
                        this.chapter = chapter;
-                       
+
                        int max = getStory().getChapters().size();
                        navigationButtons.get(0).setEnabled(chapter > 0);
                        navigationButtons.get(1).setEnabled(chapter > 0);
                        navigationButtons.get(2).setEnabled(chapter > 0);
                        navigationButtons.get(3).setEnabled(chapter < max);
                        navigationButtons.get(4).setEnabled(chapter < max);
-                       
+
                        Chapter chap;
                        String name;
                        if (chapter == 0) {
@@ -128,7 +136,8 @@ public class TuiReaderStoryWindow extends TWindow {
                                name = String.format(" %s", chap.getName());
                        } else {
                                chap = getStory().getChapters().get(chapter - 1);
-                               name = String.format(" %d/%d: %s", chapter, max, chap.getName());
+                               name = String
+                                               .format(" %d/%d: %s", chapter, max, chap.getName());
                        }
 
                        while (name.length() < getWidth() - chapterName.getX()) {
@@ -157,7 +166,7 @@ public class TuiReaderStoryWindow extends TWindow {
        private Story getStory() {
                if (story == null) {
                        // TODO: progress bar?
-                       story = Instance.getLibrary().getStory(meta.getLuid(), null);
+                       story = lib.getStory(meta.getLuid(), null);
                }
                return story;
        }