Example usage for android.text.style TextAppearanceSpan getTextStyle

List of usage examples for android.text.style TextAppearanceSpan getTextStyle

Introduction

In this page you can find the example usage for android.text.style TextAppearanceSpan getTextStyle.

Prototype

public int getTextStyle() 

Source Link

Document

Returns the text style specified by this span, or 0 if it does not specify one.

Usage

From source file:tk.wasdennnoch.androidn_ify.utils.NotificationColorUtil.java

private TextAppearanceSpan processTextAppearanceSpan(TextAppearanceSpan span) {
    ColorStateList colorStateList = span.getTextColor();
    if (colorStateList != null) {
        int[] colors = (int[]) XposedHelpers.callMethod(colorStateList, "getColors");
        boolean changed = false;
        for (int i = 0; i < colors.length; i++) {
            if (ImageUtils.isGrayscale(colors[i])) {

                // Allocate a new array so we don't change the colors in the old color state
                // list.
                if (!changed) {
                    colors = Arrays.copyOf(colors, colors.length);
                }//from w  ww  .j av a2 s . c  om
                colors[i] = processColor(colors[i]);
                changed = true;
            }
        }
        if (changed) {
            return new TextAppearanceSpan(span.getFamily(), span.getTextStyle(), span.getTextSize(),
                    new ColorStateList((int[][]) XposedHelpers.callMethod(colorStateList, "getStates"), colors),
                    span.getLinkTextColor());
        }
    }
    return span;
}