Java Code Examples for android.text.Spannable#SPAN_PRIORITY_SHIFT

The following examples show how to use android.text.Spannable#SPAN_PRIORITY_SHIFT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RNTextSizeSpannedText.java    From react-native-text-size with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static void setSpanOperation(
        Spannable str,
        int end,
        int priority,
        Object span
) {
    // Here all spans will automatically extend from the start to the end of the text.
    int spanFlags = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
    spanFlags |= (priority << Spannable.SPAN_PRIORITY_SHIFT) & Spannable.SPAN_PRIORITY;

    str.setSpan(span, 0, end, spanFlags);
}
 
Example 2
Source File: ReactBaseTextShadowNode.java    From react-native-GPay with MIT License 5 votes vote down vote up
public void execute(SpannableStringBuilder sb, int priority) {
  // All spans will automatically extend to the right of the text, but not the left - except
  // for spans that start at the beginning of the text.
  int spanFlags = Spannable.SPAN_EXCLUSIVE_INCLUSIVE;
  if (start == 0) {
    spanFlags = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
  }

  spanFlags &= ~Spannable.SPAN_PRIORITY;
  spanFlags |= (priority << Spannable.SPAN_PRIORITY_SHIFT) & Spannable.SPAN_PRIORITY;

  sb.setSpan(what, start, end, spanFlags);
}