Skip to content

Commit

Permalink
fix(android): improve textColorStateList validation
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews authored and sgtcoolguy committed Jun 8, 2020
1 parent ff57e3a commit e9c58c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ public void addTab(TabProxy tabProxy)
*/
protected ColorStateList textColorStateList(TiViewProxy tabProxy, int stateToUse)
{
if (getProxy() == null || tabProxy == null) {
return null;
}

int[][] textColorStates = new int[][] { new int[] { -stateToUse }, new int[] { stateToUse } };
int[] textColors = { this.textColorInt, this.textColorInt };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package ti.modules.titanium.ui.widget.tabgroup;

import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
Expand Down Expand Up @@ -245,8 +246,10 @@ public void updateTabTitleColor(int index)
//TIMOB-27830: Update text color after layout for change to take effect.
tabLayout.addOnLayoutChangeListener(
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
if (tabProxy != null) {
textView.setTextColor(textColorStateList(tabProxy, android.R.attr.state_selected));
final ColorStateList colorStateList =
textColorStateList(tabProxy, android.R.attr.state_selected);
if (colorStateList != null) {
textView.setTextColor(colorStateList);
}
});
}
Expand Down

0 comments on commit e9c58c3

Please sign in to comment.