class NavigationHelper {

  static NavigationIndices increaseIndex(RouteProgress routeProgress,
                                         NavigationIndices previousIndices) {
    DirectionsRoute route = routeProgress.directionsRoute();
    int previousStepIndex = previousIndices.stepIndex();
    int previousLegIndex = previousIndices.legIndex();
    int routeLegSize = route.legs().size();
    int legStepSize = route.legs().get(routeProgress.legIndex()).steps().size();

    boolean isOnLastLeg = previousLegIndex == routeLegSize - 1;
    boolean isOnLastStep = previousStepIndex == legStepSize - 1;

    if (isOnLastStep && !isOnLastLeg) {
      return NavigationIndices.create((previousLegIndex + 1), 0);
    }

    if (isOnLastStep) {
      return previousIndices;
    }
    return NavigationIndices.create(previousLegIndex, (previousStepIndex + 1));
  }

  private  NavigationHelper();

}