private void fixOverlappedSegments(int currentSegment) {
    if (currentSegment >= 0) {
      int currentSegmentStart = getSegments().getSegmentStart(currentSegment);
      int currentSegmentEnd = getSegments().getSegmentEnd(currentSegment);
      for (int i = 0; i < getSegments().getSegmentsCount(); i++) {
        if (i > currentSegment) {
          final int startOffset = getSegments().getSegmentStart(i);
          if (currentSegmentStart <= startOffset && startOffset < currentSegmentEnd) {
            getSegments().replaceSegmentAt(i, currentSegmentEnd, Math.max(getSegments().getSegmentEnd(i), currentSegmentEnd), true);
          }
        }
        else if (i < currentSegment) {
          final int endOffset = getSegments().getSegmentEnd(i);
          if (currentSegmentStart < endOffset && endOffset <= currentSegmentEnd) {
            getSegments().replaceSegmentAt(i, Math.min(getSegments().getSegmentStart(i), currentSegmentStart), currentSegmentStart, true);
          }
        }
      }
    }
  }
private void fixOverlappedSegments(int currentSegment)