예제 #1
0
  public void navigateTo(String rawHref) {

    this.prevIndex = this.getIndex();
    this.prevPos = this.getPosition();

    // URLDecode the href, so it does not contain %20 etc.
    String href =
        URLDecoder.decode(StringUtil.substringBefore(rawHref, Constants.FRAGMENT_SEPARATOR_CHAR));

    // Don't decode the anchor.
    String anchor = StringUtil.substringAfterLast(rawHref, Constants.FRAGMENT_SEPARATOR_CHAR);

    if (!"".equals(anchor)) {
      this.storedAnchor = anchor;
    }

    // Just an anchor and no href; resolve it on this page
    if (href.length() == 0) {
      restorePosition();
    } else {

      this.strategy.clearText();
      this.strategy.setPosition(0);

      if (this.spine.navigateByHref(href)) {
        loadText();
      } else {
        executeTask(new LoadTextTask(), href);
      }
    }
  }
예제 #2
0
    @Override
    protected List<List<Integer>> doInBackground(Object... params) {

      try {
        List<List<Integer>> offsets = new ArrayList<List<Integer>>();

        for (int i = 0; i < spine.size(); i++) {
          offsets.add(getOffsetsForResource(i));
        }

        String file = StringUtil.substringAfterLast(fileName, '/');
        configuration.setPageOffsets(file, offsets);

        return offsets;

      } catch (IOException io) {
        LOG.error("Could not read pagenumers", io);
      }

      return null;
    }
예제 #3
0
    private void setBook(Book book) {

      BookView.this.book = book;
      BookView.this.spine = new PageTurnerSpine(book);

      String file = StringUtil.substringAfterLast(fileName, '/');

      BookView.this.spine.navigateByIndex(BookView.this.storedIndex);

      if (configuration.isShowPageNumbers()) {

        List<List<Integer>> offsets = configuration.getPageOffsets(file);

        if (offsets != null && offsets.size() > 0) {
          spine.setPageOffsets(offsets);
          needToCalcPageNumbers = false;
        } else {
          needToCalcPageNumbers = true;
        }
      }
    }