Ejemplo n.º 1
0
    static Action newReplaceText(CharSequence text, int start, int end) {
      if (start < 0 || start > end) {
        Log.e(LOGTAG, "invalid replace text offsets: " + start + " to " + end);
        throw new IllegalArgumentException("invalid replace text offsets");
      }

      int actionType = TYPE_REPLACE_TEXT;

      if (text instanceof Spanned) {
        final Spanned spanned = (Spanned) text;
        final Object[] spans = spanned.getSpans(0, spanned.length(), Object.class);

        for (Object span : spans) {
          if ((spanned.getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0) {
            actionType = TYPE_COMPOSE_TEXT;
            break;
          }
        }
      }

      final Action action = new Action(actionType);
      action.mSequence = text;
      action.mStart = start;
      action.mEnd = end;
      return action;
    }
Ejemplo n.º 2
0
 private static CharSequence removeJumpingBeansSpans(Spanned text) {
   SpannableStringBuilder sbb = new SpannableStringBuilder(text.toString());
   Object[] spans = text.getSpans(0, text.length(), Object.class);
   for (Object span : spans) {
     if (!(span instanceof JumpingBeansSpan)) {
       sbb.setSpan(span, text.getSpanStart(span), text.getSpanEnd(span), text.getSpanFlags(span));
     }
   }
   return sbb;
 }
Ejemplo n.º 3
0
  private static int getActive(CharSequence text, Object meta, int on, int lock) {
    if (!(text instanceof Spanned)) {
      return 0;
    }

    Spanned sp = (Spanned) text;
    int flag = sp.getSpanFlags(meta);

    if (flag == LOCKED) {
      return lock;
    } else if (flag != 0) {
      return on;
    } else {
      return 0;
    }
  }