public static void applyStyles ( Context ctx , Spannable text , List < StyleContainer > styleContainers , List < CharacterStyle > styles , HashMap < String , List < CharacterStyle > > stylesFor ) { for ( StyleContainer styleContainer : styleContainers ) { if ( styleContainer . style != null ) { text . setSpan ( styleContainer . style , styleContainer . startIndex , styleContainer . endIndex , styleContainer . flags ) ; } else if ( styleContainer . span != null ) { text . setSpan ( styleContainer . span , styleContainer . startIndex , styleContainer . endIndex , styleContainer . flags ) ; } else { text . setSpan ( new IconicsTypefaceSpan ( "sans-serif" , styleContainer . font . getTypeface ( ctx ) ) , styleContainer . startIndex , styleContainer . endIndex , Spannable . SPAN_EXCLUSIVE_EXCLUSIVE ) ; } if ( stylesFor != null && stylesFor . containsKey ( styleContainer . icon ) ) { for ( CharacterStyle style : stylesFor . get ( styleContainer . icon ) ) { text . setSpan ( CharacterStyle . wrap ( style ) , styleContainer . startIndex , styleContainer . endIndex , styleContainer . flags ) ; } } else if ( styles != null ) { for ( CharacterStyle style : styles ) { text . setSpan ( CharacterStyle . wrap ( style ) , styleContainer . startIndex , styleContainer . endIndex , styleContainer . flags ) ; } } } }
Applies all given styles on the given Spannable