code: public int nextSpanTransition(int start, int limit, Class kind) {
          int count = mSpanCount;
          Object[] spans = mSpans;
          int[] starts = mSpanStarts;
          int[] ends = mSpanEnds;
          int gapstart = mGapStart;
          int gaplen = mGapLength;
  
          if (kind == null) {
              kind = Object.class;
          }
  
          for (int i = 0; i < count; i++) {
              int st = starts[i];
              int en = ends[i];
  
              if (st > gapstart)
                  st -= gaplen;
              if (en > gapstart)
                  en -= gaplen;
  
              if (st > start && st < limit && kind.isInstance(spans[i]))
                  limit = st;
              if (en > start && en < limit && kind.isInstance(spans[i]))
                  limit = en;
          }
  
          return limit;
      }
docs: Return the next offset after <code>start</code> but less than or
  equal to <code>limit</code> where a span of the specified type
  begins or ends.