Beispiel #1
0
 private void onPreferencesUpdate(int resultCode) {
   final FBReaderApp fbReader = (FBReaderApp) FBReaderApp.Instance();
   switch (resultCode) {
     case RESULT_DO_NOTHING:
       break;
     case RESULT_REPAINT:
       {
         AndroidFontUtil.clearFontCache();
         final BookModel model = fbReader.Model;
         if (model != null) {
           final Book book = model.Book;
           if (book != null) {
             book.reloadInfoFromDatabase();
             ZLTextHyphenator.Instance().load(book.getLanguage());
           }
         }
         fbReader.clearTextCaches();
         fbReader.getViewWidget().repaint();
         break;
       }
     case RESULT_RELOAD_BOOK:
       fbReader.reloadBook();
       break;
   }
 }
Beispiel #2
0
  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();
  }
Beispiel #3
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   final FBReaderApp fbreader = (FBReaderApp) FBReaderApp.Instance();
   switch (requestCode) {
     case REPAINT_CODE:
       {
         final BookModel model = fbreader.Model;
         if (model != null) {
           final Book book = model.Book;
           if (book != null) {
             book.reloadInfoFromDatabase();
             ZLTextHyphenator.Instance().load(book.getLanguage());
           }
         }
         fbreader.clearTextCaches();
         fbreader.getViewWidget().repaint();
         break;
       }
     case CANCEL_CODE:
       fbreader.runCancelAction(resultCode - 1);
       break;
   }
 }