示例#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;
    }

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

    if (this.spine.navigateByHref(href)) {
      loadText();
    } else {
      new LoadTextTask().execute(href);
    }
  }
示例#2
0
  public void goBackInHistory() {

    this.strategy.clearText();
    this.spine.navigateByIndex(this.prevIndex);
    strategy.setPosition(this.prevPos);

    this.storedAnchor = null;
    this.prevIndex = -1;
    this.prevPos = -1;

    loadText();
  }
示例#3
0
  private void doNavigation(int index) {

    // Check if we're already in the right part of the book
    if (index == this.getIndex()) {
      restorePosition();
      return;
    }

    this.prevIndex = this.getIndex();

    this.storedIndex = index;
    this.strategy.clearText();
    this.spine.navigateByIndex(index);

    loadText();
  }
示例#4
0
 /** Loads the text and saves the restored position. */
 public void restore() {
   strategy.clearText();
   loadText();
 }