Skip to content

Commit 75e6f79

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Fix measure of ReactSlider for Android API < 21
Summary: This diff avoids calling to the method setStateListAnimator for users running in Android API < 21 (This method did not exist in Android API < 21) changelog: [Android][Fix] Fix crash while measuring ReactSlider in Android API < 21 Reviewed By: lunaleaps Differential Revision: D22164574 fbshipit-source-id: 8163f99eeb78302fc75e2c4938330c699ca8d363
1 parent c3d4d2a commit 75e6f79

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/slider/ReactSlider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public ReactSlider(Context context, @Nullable AttributeSet attrs, int style) {
5353
disableStateListAnimatorIfNeeded();
5454
}
5555

56-
private void disableStateListAnimatorIfNeeded() {
56+
/* package */ void disableStateListAnimatorIfNeeded() {
5757
// We disable the state list animator for Android 6 and 7; this is a hack to prevent T37452851
5858
// and https://github.com/facebook/react-native/issues/9979
5959
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M

ReactAndroid/src/main/java/com/facebook/react/views/slider/ReactSliderManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ public long measure(
7272
float height,
7373
YogaMeasureMode heightMode) {
7474
if (!mMeasured) {
75-
SeekBar reactSlider = new ReactSlider(getThemedContext(), null, STYLE);
75+
ReactSlider reactSlider = new ReactSlider(getThemedContext(), null, STYLE);
7676
// reactSlider is used for measurements purposes, it is not necessary to set a
7777
// StateListAnimator.
7878
// It is not safe to access StateListAnimator from a background thread.
79-
reactSlider.setStateListAnimator(null);
79+
reactSlider.disableStateListAnimatorIfNeeded();
8080
final int spec =
8181
View.MeasureSpec.makeMeasureSpec(
8282
ViewGroup.LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED);

0 commit comments

Comments
 (0)