2020import android .widget .TextView ;
2121
2222import com .noober .background .drawable .DrawableFactory ;
23+ import com .noober .background .drawable .TextViewFactory ;
2324
2425import java .lang .reflect .Constructor ;
2526import java .lang .reflect .InvocationTargetException ;
@@ -85,16 +86,16 @@ private static View setViewBackground(String name, Context context, AttributeSet
8586 TypedArray animTa = context .obtainStyledAttributes (attrs , R .styleable .bl_anim );
8687 TypedArray multiSelTa = context .obtainStyledAttributes (attrs , R .styleable .background_multi_selector );
8788 TypedArray multiTextTa = context .obtainStyledAttributes (attrs , R .styleable .background_multi_selector_text );
88-
89+ TypedArray textViewTa = context . obtainStyledAttributes ( attrs , R . styleable . bl_text );
8990 TypedArray selectorPre21Ta = null ;
9091 if (Build .VERSION .SDK_INT < Build .VERSION_CODES .LOLLIPOP ) {
9192 selectorPre21Ta = context .obtainStyledAttributes (attrs , R .styleable .background_selector_pre_21 );
9293 }
9394
9495 try {
9596 if (typedArray .getIndexCount () == 0 && selectorTa .getIndexCount () == 0 && pressTa .getIndexCount () == 0
96- && textTa .getIndexCount () == 0 && buttonTa .getIndexCount () == 0 && animTa .getIndexCount () == 0
97- && multiSelTa .getIndexCount () == 0 && multiTextTa .getIndexCount () == 0 ) {
97+ && textTa .getIndexCount () == 0 && buttonTa .getIndexCount () == 0 && animTa .getIndexCount () == 0
98+ && multiSelTa .getIndexCount () == 0 && multiTextTa . getIndexCount () == 0 && textViewTa .getIndexCount () == 0 ) {
9899 return view ;
99100 }
100101 if (view == null ) {
@@ -153,10 +154,13 @@ private static View setViewBackground(String name, Context context, AttributeSet
153154 ((TextView ) view ).setTextColor (DrawableFactory .getTextSelectorColor (textTa ));
154155 } else if (view instanceof TextView && multiTextTa .getIndexCount () > 0 ) {
155156 ((TextView ) view ).setTextColor (DrawableFactory .getMultiTextColorSelectorColorCreator (context , multiTextTa ));
157+ } else if (view instanceof TextView && textViewTa .getIndexCount () > 0 ) {
158+ TextViewFactory .setTextGradientColor (context , attrs , (TextView ) view );
156159 }
157160
161+
158162 if (typedArray .getBoolean (R .styleable .background_bl_ripple_enable , false ) &&
159- typedArray .hasValue (R .styleable .background_bl_ripple_color )) {
163+ typedArray .hasValue (R .styleable .background_bl_ripple_color )) {
160164 int color = typedArray .getColor (R .styleable .background_bl_ripple_color , 0 );
161165 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
162166 Drawable contentDrawable = (stateListDrawable == null ? drawable : stateListDrawable );
@@ -180,7 +184,7 @@ private static View setViewBackground(String name, Context context, AttributeSet
180184 final Context currentContext = view .getContext ();
181185 final Class parentClass = currentContext .getClass ();
182186 final Method method = getMethod (parentClass , methodName );
183- if (method != null ) {
187+ if (method != null ){
184188 view .setOnClickListener (new View .OnClickListener () {
185189 @ Override
186190 public void onClick (View view ) {
@@ -211,13 +215,13 @@ public void onClick(View view) {
211215 animTa .recycle ();
212216 multiSelTa .recycle ();
213217 multiTextTa .recycle ();
218+ textViewTa .recycle ();
214219 if (selectorPre21Ta != null ) {
215220 selectorPre21Ta .recycle ();
216221 }
217222 }
218223 }
219224
220-
221225 private static Method getMethod (Class clazz , String methodName ) {
222226 Method method = null ;
223227 HashMap <String , Method > methodHashMap = methodMap .get (clazz .getCanonicalName ());
@@ -376,7 +380,7 @@ private static View createView(Context context, String name, String prefix) thro
376380 try {
377381 if (constructor == null ) {
378382 Class <? extends View > clazz = context .getClassLoader ().loadClass (
379- prefix != null ? (prefix + name ) : name ).asSubclass (View .class );
383+ prefix != null ? (prefix + name ) : name ).asSubclass (View .class );
380384
381385 constructor = clazz .getConstructor (sConstructorSignature );
382386 sConstructorMap .put (name , constructor );
@@ -394,13 +398,14 @@ public View onCreateView(View parent, String name, Context context, AttributeSet
394398 return onCreateView (name , context , attrs );
395399 }
396400
397-
398401 private static boolean hasGradientState (TypedArray typedArray ) {
399402 return typedArray .hasValue (R .styleable .background_bl_checkable_gradient_startColor ) ||
400- typedArray .hasValue (R .styleable .background_bl_checked_gradient_startColor ) ||
401- typedArray .hasValue (R .styleable .background_bl_enabled_gradient_startColor ) ||
402- typedArray .hasValue (R .styleable .background_bl_selected_gradient_startColor ) ||
403- typedArray .hasValue (R .styleable .background_bl_pressed_gradient_startColor ) ||
404- typedArray .hasValue (R .styleable .background_bl_focused_gradient_startColor );
403+ typedArray .hasValue (R .styleable .background_bl_checked_gradient_startColor ) ||
404+ typedArray .hasValue (R .styleable .background_bl_enabled_gradient_startColor ) ||
405+ typedArray .hasValue (R .styleable .background_bl_selected_gradient_startColor ) ||
406+ typedArray .hasValue (R .styleable .background_bl_pressed_gradient_startColor ) ||
407+ typedArray .hasValue (R .styleable .background_bl_focused_gradient_startColor );
405408 }
406409}
410+
411+
0 commit comments