Safely run VoiceNoteProximityWakeLockManager cleanup.

This commit is contained in:
Nicholas Tinsley
2023-08-17 11:17:19 -04:00
parent 1fd9609810
commit 451ce74fa4

View File

@@ -117,8 +117,10 @@ class VoiceNoteMediaController(val activity: FragmentActivity, private var postp
}
override fun onDestroy(owner: LifecycleOwner) {
voiceNoteProximityWakeLockManager.unregisterCallbacksAndRelease()
voiceNoteProximityWakeLockManager.unregisterFromLifecycle()
if (this::voiceNoteProximityWakeLockManager.isInitialized) {
voiceNoteProximityWakeLockManager.unregisterCallbacksAndRelease()
voiceNoteProximityWakeLockManager.unregisterFromLifecycle()
}
activity.lifecycle.removeObserver(this)
super.onDestroy(owner)
}