Updated on 2026-08-14
This commit is contained in:
parent
52bf5cbb58
commit
9bd16deeb4
23 changed files with 245 additions and 151 deletions
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<SmellBaseline>
|
||||
<ManuallySuppressedIssues/>
|
||||
<CurrentIssues>
|
||||
<ID>CastNullableToNonNullableType:DefaultDeviceFlipDetector.kt$DefaultDeviceFlipDetector$as</ID>
|
||||
</CurrentIssues>
|
||||
</SmellBaseline>
|
||||
|
|
@ -16,11 +16,19 @@ import javax.inject.Singleton
|
|||
|
||||
@Singleton
|
||||
class DefaultDeviceFlipDetector @Inject constructor(
|
||||
@ApplicationContext context: Context,
|
||||
@ApplicationContext private val context: Context,
|
||||
) : DeviceFlipDetector, DefaultLifecycleObserver {
|
||||
|
||||
private val sensorManager = context.getSystemService(Context.SENSOR_SERVICE) as SensorManager
|
||||
private val gravitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY)
|
||||
private val sensorManager: SensorManager by lazy {
|
||||
val manager = context.getSystemService(Context.SENSOR_SERVICE) as? SensorManager
|
||||
|
||||
requireNotNull(manager)
|
||||
}
|
||||
|
||||
private val gravitySensor by lazy {
|
||||
sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY)
|
||||
}
|
||||
|
||||
private val isResumedState = AtomicBoolean(false)
|
||||
|
||||
override fun onPause(owner: LifecycleOwner) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue