Skip to content

Commit 198a6ac

Browse files
fcopardowojteg1337
authored andcommitted
Evaluates getThumb before accesing it for setting setting the thumb tint color (#120)
1 parent 5220303 commit 198a6ac

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ public Class getShadowNodeClass() {
128128
@Override
129129
protected ReactSlider createViewInstance(ThemedReactContext context) {
130130
ReactSlider slider = new ReactSlider(context, null, STYLE);
131-
131+
132132
if (Build.VERSION.SDK_INT >= 21) {
133-
/**
133+
/**
134134
* The "splitTrack" parameter should have "false" value,
135135
* otherwise the SeekBar progress line doesn't appear when it is rotated.
136136
*/
137137
slider.setSplitTrack(false);
138138
}
139-
139+
140140
return slider;
141141
}
142142

@@ -169,10 +169,12 @@ public void setStep(ReactSlider view, double value) {
169169

170170
@ReactProp(name = "thumbTintColor", customType = "Color")
171171
public void setThumbTintColor(ReactSlider view, Integer color) {
172-
if (color == null) {
173-
view.getThumb().clearColorFilter();
174-
} else {
175-
view.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
172+
if (view.getThumb() != null) {
173+
if (color == null) {
174+
view.getThumb().clearColorFilter();
175+
} else {
176+
view.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);
177+
}
176178
}
177179
}
178180

@@ -206,7 +208,7 @@ public void setMaximumTrackTintColor(ReactSlider view, Integer color) {
206208
background.setColorFilter(color, PorterDuff.Mode.SRC_IN);
207209
}
208210
}
209-
211+
210212
@ReactProp(name = "inverted", defaultBoolean = false)
211213
public void setInverted(ReactSlider view, boolean inverted) {
212214
if (inverted) view.setScaleX(-1f);

0 commit comments

Comments
 (0)