fix crash

This commit is contained in:
Milos Kozak 2022-09-22 12:34:03 +02:00
parent b38cb58338
commit 9bdebd7667

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.utils.ui
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Service import android.app.Service
import android.content.Context import android.content.Context
import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.os.Message import android.os.Message
@ -146,14 +147,17 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager .getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
if (manager.isEnabled) { if (manager.isEnabled) {
val valueDescription = formatter?.format(currentValue) val valueDescription = formatter?.format(currentValue)
AccessibilityEvent().apply { @Suppress("DEPRECATION")
eventType = AccessibilityEvent.TYPE_ANNOUNCEMENT (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) AccessibilityEvent()
className = javaClass.name else AccessibilityEvent.obtain())
packageName = context.packageName .apply {
text.add(valueDescription) eventType = AccessibilityEvent.TYPE_ANNOUNCEMENT
}.also { className = javaClass.name
manager.sendAccessibilityEvent(it) packageName = context.packageName
} text.add(valueDescription)
}.also {
manager.sendAccessibilityEvent(it)
}
} }
} }