mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c3d4d2a3d2
commit
75e6f7961f
@@ -53,7 +53,7 @@ public class ReactSlider extends AppCompatSeekBar {
|
||||
disableStateListAnimatorIfNeeded();
|
||||
}
|
||||
|
||||
private void disableStateListAnimatorIfNeeded() {
|
||||
/* package */ void disableStateListAnimatorIfNeeded() {
|
||||
// We disable the state list animator for Android 6 and 7; this is a hack to prevent T37452851
|
||||
// and https://github.com/facebook/react-native/issues/9979
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
|
||||
@@ -72,11 +72,11 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider>
|
||||
float height,
|
||||
YogaMeasureMode heightMode) {
|
||||
if (!mMeasured) {
|
||||
SeekBar reactSlider = new ReactSlider(getThemedContext(), null, STYLE);
|
||||
ReactSlider reactSlider = new ReactSlider(getThemedContext(), null, STYLE);
|
||||
// reactSlider is used for measurements purposes, it is not necessary to set a
|
||||
// StateListAnimator.
|
||||
// It is not safe to access StateListAnimator from a background thread.
|
||||
reactSlider.setStateListAnimator(null);
|
||||
reactSlider.disableStateListAnimatorIfNeeded();
|
||||
final int spec =
|
||||
View.MeasureSpec.makeMeasureSpec(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED);
|
||||
|
||||
Reference in New Issue
Block a user