private static int toPercent(double progress, boolean finished) {
    int percent = (int)(progress * 100);
    return percent == 100 && !finished ? 99 : percent;
  }
private static int toPercent(double progress, boolean finished)