コード例 #1
0
ファイル: FBReaderApp.java プロジェクト: nvdnkpr/FBReaderJ
  synchronized void openBookInternal(Book book, Bookmark bookmark) {
    if (book == null) {
      book = Library.Instance().getRecentBook();
      if (book == null || !book.File.exists()) {
        book = Book.getByFile(Library.getHelpFile());
      }
      if (book == null) {
        return;
      }
    }
    if (Model != null) {
      if (bookmark == null & book.File.getPath().equals(Model.Book.File.getPath())) {
        return;
      }
    }

    if (book != null) {
      onViewChanged();

      if (Model != null) {
        Model.Book.storePosition(BookTextView.getStartCursor());
      }
      BookTextView.setModel(null);
      FootnoteView.setModel(null);
      clearTextCaches();

      Model = null;
      System.gc();
      System.gc();
      try {
        Model = BookModel.createModel(book);
        ZLTextHyphenator.Instance().load(book.getLanguage());
        BookTextView.setModel(Model.getTextModel());
        BookTextView.gotoPosition(book.getStoredPosition());
        if (bookmark == null) {
          setView(BookTextView);
        } else {
          gotoBookmark(bookmark);
        }
        Library.Instance().addBookToRecentList(book);
        final StringBuilder title = new StringBuilder(book.getTitle());
        if (!book.authors().isEmpty()) {
          boolean first = true;
          for (Author a : book.authors()) {
            title.append(first ? " (" : ", ");
            title.append(a.DisplayName);
            first = false;
          }
          title.append(")");
        }
        setTitle(title.toString());
      } catch (BookReadingException e) {
        processException(e);
      }
    }
    getViewWidget().reset();
    getViewWidget().repaint();
  }
コード例 #2
0
ファイル: OEBBookReader.java プロジェクト: andhof/UPBReader
 OEBBookReader(BookModel model) {
   myModelReader = new BookReader(model);
   model.setLabelResolver(
       new BookModel.LabelResolver() {
         public List<String> getCandidates(String id) {
           final int index = id.indexOf("#");
           return index > 0
               ? Collections.<String>singletonList(id.substring(0, index))
               : Collections.<String>emptyList();
         }
       });
 }
コード例 #3
0
ファイル: FBReaderApp.java プロジェクト: nvdnkpr/FBReaderJ
 public void gotoBookmark(Bookmark bookmark) {
   final String modelId = bookmark.ModelId;
   if (modelId == null) {
     addInvisibleBookmark();
     BookTextView.gotoPosition(bookmark);
     setView(BookTextView);
   } else {
     FootnoteView.setModel(Model.getFootnoteModel(modelId));
     FootnoteView.gotoPosition(bookmark);
     setView(FootnoteView);
   }
   getViewWidget().repaint();
 }
コード例 #4
0
ファイル: FBReaderApp.java プロジェクト: nvdnkpr/FBReaderJ
 public void tryOpenFootnote(String id) {
   if (Model != null) {
     myJumpEndPosition = null;
     myJumpTimeStamp = null;
     BookModel.Label label = Model.getLabel(id);
     if (label != null) {
       if (label.ModelId == null) {
         if (getTextView() == BookTextView) {
           addInvisibleBookmark();
           myJumpEndPosition = new ZLTextFixedPosition(label.ParagraphIndex, 0, 0);
           myJumpTimeStamp = new Date();
         }
         BookTextView.gotoPosition(label.ParagraphIndex, 0, 0);
         setView(BookTextView);
       } else {
         FootnoteView.setModel(Model.getFootnoteModel(label.ModelId));
         setView(FootnoteView);
         FootnoteView.gotoPosition(label.ParagraphIndex, 0, 0);
       }
       getViewWidget().repaint();
     }
   }
 }