Android examples for Graphics:Spannable
get Composing Spans
//package com.java2s; import android.support.annotation.NonNull; import android.text.Spanned; import java.util.ArrayList; import java.util.List; public class Main { /**//from ww w . ja v a 2 s . co m * @return Temporary spans, often applied by the keyboard to provide hints such as typos. * * @see {@link android.view.inputmethod.BaseInputConnection#removeComposingSpans} * @see {@link android.inputmethod.latin.inputlogic.InputLogic#setComposingTextInternalWithBackgroundColor} */ @NonNull public static List<Object> getComposingSpans(@NonNull Spanned spanned, int start, int end) { // TODO: replace with Apache CollectionUtils.filter(). List<Object> ret = new ArrayList<>(); for (Object span : getSpans(spanned, start, end)) { if (isComposingSpan(spanned, span)) { ret.add(span); } } return ret; } public static Object[] getSpans(@NonNull Spanned spanned, int start, int end) { Class<Object> anyType = Object.class; return spanned.getSpans(start, end, anyType); } public static boolean isComposingSpan(@NonNull Spanned spanned, Object span) { return isFlaggedSpan(spanned, span, Spanned.SPAN_COMPOSING); } public static boolean isFlaggedSpan(@NonNull Spanned spanned, Object span, int flags) { return (spanned.getSpanFlags(span) & flags) == flags; } }