Ejemplo n.º 1
0
  public void navigateTo(int index, int position) {

    this.prevPos = this.getPosition();
    this.strategy.setPosition(position);

    doNavigation(index);
  }
Ejemplo n.º 2
0
  public void navigateToPercentage(int percentage) {

    if (spine == null) {
      return;
    }

    double targetPoint = (double) percentage / 100d;
    List<Double> percentages = this.spine.getRelativeSizes();

    if (percentages == null || percentages.isEmpty()) {
      return;
    }

    int index = 0;
    double total = 0;

    for (; total < targetPoint && index < percentages.size(); index++) {
      total = total + percentages.get(index);
    }

    index--;

    // Work-around for when we get multiple events.
    if (index < 0 || index >= percentages.size()) {
      return;
    }

    double partBefore = total - percentages.get(index);
    double progressInPart = (targetPoint - partBefore) / percentages.get(index);

    this.prevPos = this.getPosition();
    this.strategy.setRelativePosition(progressInPart);

    doNavigation(index);
  }