Update nikiroo-utils, remove Instance.syserr/trace
[nikiroo-utils.git] / src / be / nikiroo / fanfix / reader / TuiReader.java
index 91b62683aff9de15da1645a7ac08e62cacb7c916..30b9dce5962972b86eaf27aadb5f31e0b81d0aa8 100644 (file)
@@ -1,12 +1,10 @@
 package be.nikiroo.fanfix.reader;
 
 import java.io.IOException;
-import java.util.List;
 
 import jexer.TApplication;
 import jexer.TApplication.BackendType;
 import be.nikiroo.fanfix.Instance;
-import be.nikiroo.fanfix.data.MetaData;
 
 /**
  * This {@link Reader}is based upon the TUI widget library 'jexer'
@@ -49,50 +47,25 @@ class TuiReader extends BasicReader {
                return backendType;
        }
 
-       public void read(int chapter) throws IOException {
-               if (getStory() == null) {
-                       throw new IOException("No story to read");
-               }
-
-               start(getStory().getMeta(), chapter);
-       }
-
-       public void browse(String source) {
-               start(getLibrary().getListBySource(source));
-       }
-
-       /**
-        * Start the application with the given stories.
-        * 
-        * @param metas
-        *            the stories to display
-        */
-       private void start(List<MetaData> metas) {
+       @Override
+       public void read() throws IOException {
                try {
-                       TuiReaderApplication app = new TuiReaderApplication(metas, this,
+                       TuiReaderApplication app = new TuiReaderApplication(this,
                                        guessBackendType());
                        new Thread(app).start();
                } catch (Exception e) {
-                       Instance.syserr(e);
+                       Instance.getTraceHandler().error(e);
                }
        }
 
-       /**
-        * Start the application with the given {@link MetaData} at the given open
-        * chapter.
-        * 
-        * @param meta
-        *            the story to display
-        * @param chapter
-        *            the chapter to open
-        */
-       private void start(MetaData meta, int chapter) {
+       @Override
+       public void browse(String source) {
                try {
-                       TuiReaderApplication app = new TuiReaderApplication(meta, chapter,
-                                       this, guessBackendType());
+                       TuiReaderApplication app = new TuiReaderApplication(this, source,
+                                       guessBackendType());
                        new Thread(app).start();
                } catch (Exception e) {
-                       Instance.syserr(e);
+                       Instance.getTraceHandler().error(e);
                }
        }
 }