File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
profile_prx/src/main/java/no/nordicsemi/android/prx/repository Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,21 @@ internal class AlarmHandler @Inject constructor(
12
12
private val context : Context
13
13
) {
14
14
15
- private val highLevelRingtone = RingtoneManager .getRingtone(context, RingtoneManager .getDefaultUri(RingtoneManager .TYPE_ALARM )).apply {
16
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
17
- volume = 1f
15
+ private val highLevelRingtone = RingtoneManager
16
+ .getRingtone(context, RingtoneManager .getDefaultUri(RingtoneManager .TYPE_ALARM ))
17
+ ?.apply {
18
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
19
+ volume = 1f
20
+ }
18
21
}
19
- }
20
22
21
- private val mediumLevelRingtone = RingtoneManager .getRingtone(context, RingtoneManager .getDefaultUri(RingtoneManager .TYPE_RINGTONE )).apply {
22
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
23
- volume = 0.5f
23
+ private val mediumLevelRingtone = RingtoneManager
24
+ .getRingtone(context, RingtoneManager .getDefaultUri(RingtoneManager .TYPE_RINGTONE ))
25
+ ?.apply {
26
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
27
+ volume = 0.5f
28
+ }
24
29
}
25
- }
26
30
27
31
fun playAlarm (alarmLevel : AlarmLevel ) {
28
32
val ringtone = when (alarmLevel) {
@@ -34,7 +38,7 @@ internal class AlarmHandler @Inject constructor(
34
38
}
35
39
36
40
fun pauseAlarm () {
37
- highLevelRingtone.takeIf { it.isPlaying }?.stop()
38
- mediumLevelRingtone.takeIf { it.isPlaying }?.stop()
41
+ highLevelRingtone? .takeIf { it.isPlaying }?.stop()
42
+ mediumLevelRingtone? .takeIf { it.isPlaying }?.stop()
39
43
}
40
44
}
You can’t perform that action at this time.
0 commit comments