@@ -32,7 +32,7 @@ class HapticsModule(reactContext: ReactApplicationContext) :
3232 .build()
3333 }
3434
35- private val vibrationAttributes: Any ? by lazy {
35+ private val vibrationAttributes: VibrationAttributes ? by lazy {
3636 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
3737 VibrationAttributes .createForUsage(VibrationAttributes .USAGE_TOUCH )
3838 } else {
@@ -102,7 +102,8 @@ class HapticsModule(reactContext: ReactApplicationContext) :
102102 }
103103
104104 private fun vibrate (type : HapticsVibrationType ) {
105- if (vibrator?.hasVibrator() == false ) {
105+ val vibrator = this .vibrator ? : return
106+ if (! vibrator.hasVibrator()) {
106107 return
107108 }
108109 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
@@ -117,13 +118,8 @@ class HapticsModule(reactContext: ReactApplicationContext) :
117118 vibrator?.vibrate(effect, audioAttributes)
118119 }
119120 } else {
120- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
121- @Suppress(" DEPRECATION" )
122- vibrator?.vibrate(type.oldFallback, - 1 , audioAttributes)
123- } else {
124- @Suppress(" DEPRECATION" )
125- vibrator?.vibrate(type.oldFallback, - 1 )
126- }
121+ @Suppress(" DEPRECATION" )
122+ vibrator?.vibrate(type.oldFallback, - 1 , audioAttributes)
127123 }
128124 }
129125
0 commit comments