Esempio 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;
    }
Esempio n. 2
0
 static Action newSetSpan(Object object, int start, int end, int flags) {
   if (start < 0 || start > end) {
     Log.e(LOGTAG, "invalid span offsets: " + start + " to " + end);
     throw new IllegalArgumentException("invalid span offsets");
   }
   final Action action = new Action(TYPE_SET_SPAN);
   action.mSpanObject = object;
   action.mStart = start;
   action.mEnd = end;
   action.mSpanFlags = flags;
   return action;
 }
Esempio n. 3
0
 static Action newSetSelection(int start, int end) {
   // start == -1 when the start offset should remain the same
   // end == -1 when the end offset should remain the same
   if (start < -1 || end < -1) {
     Log.e(LOGTAG, "invalid selection offsets: " + start + " to " + end);
     throw new IllegalArgumentException("invalid selection offsets");
   }
   final Action action = new Action(TYPE_SET_SELECTION);
   action.mStart = start;
   action.mEnd = end;
   return action;
 }