small code cleanup
authorNiki Roo <niki@nikiroo.be>
Mon, 4 Mar 2019 13:26:35 +0000 (14:26 +0100)
committerNiki Roo <niki@nikiroo.be>
Mon, 4 Mar 2019 13:26:35 +0000 (14:26 +0100)
src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java
src/be/nikiroo/fanfix/reader/tui/TuiReaderStoryWindow.java
src/be/nikiroo/fanfix/supported/BasicSupport.java

index 9e991e4c743e7f31b24f0fee0f7370fd52476d03..b7109ab8d6ae55fba0e225d0604c1a6a139f89e8 100644 (file)
@@ -57,7 +57,6 @@ class TuiReaderApplication extends TApplication implements Reader {
        public TuiReaderApplication(Reader reader, String source,
                        TApplication.BackendType backend) throws Exception {
                super(backend);
-
                init(reader);
 
                main = new TuiReaderMainWindow(this);
index e4587e755917c0b2489fa1a32ce34dc1debb90db..ead70d4b0a116e58f6fdeb68ee4aae137e352004 100644 (file)
@@ -133,7 +133,10 @@ class TuiReaderStoryWindow extends TWindow {
                        String name;
                        if (chapter == 0) {
                                chap = getStory().getMeta().getResume();
-                               name = String.format(" %s", chap.getName());
+                               if (chap != null)
+                                       name = String.format(" %s", chap.getName());
+                               else
+                                       name = "[No RESUME]";
                        } else {
                                chap = getStory().getChapters().get(chapter - 1);
                                name = String
@@ -148,14 +151,17 @@ class TuiReaderStoryWindow extends TWindow {
 
                        StringBuilder builder = new StringBuilder();
                        // TODO: i18n
-                       String c = String.format("Chapter %d: %s", chapter, chap.getName());
+                       String c = String.format("Chapter %d: %s", chapter,
+                                       chap == null ? "[No RESUME]" : chap.getName());
                        builder.append(c).append("\n");
                        for (int i = 0; i < c.length(); i++) {
                                builder.append("═");
                        }
                        builder.append("\n\n");
-                       for (Paragraph para : chap) {
-                               builder.append(para.getContent()).append("\n\n");
+                       if (chap != null) {
+                               for (Paragraph para : chap) {
+                                       builder.append(para.getContent()).append("\n\n");
+                               }
                        }
                        textField.setText(builder.toString());
                        textField.reflow();
index 388f57222cf41da10d24a354626cb6409195304a..4337626c7fe60d96914eb9658df2b827823de539 100644 (file)
@@ -295,7 +295,7 @@ public abstract class BasicSupport {
                                                        getDesc(), isHtml(), null));
                }
 
-               pg.setProgress(100);
+               pg.done();
                return story;
        }
 
@@ -394,6 +394,7 @@ public abstract class BasicSupport {
                        }
 
                        pgChaps.setName("Extracting chapters");
+                       pgChaps.done();
                }
 
                pg.done();