[F] Avoid starting multiple alarms at once
This commit is contained in:
@@ -10,6 +10,7 @@ import AVFoundation
|
||||
import CoreMotion
|
||||
|
||||
var motion = CMMotionManager()
|
||||
var alarmStarted = false
|
||||
|
||||
/**
|
||||
View controlling alarm activation and dismissal
|
||||
@@ -120,6 +121,8 @@ class AlarmActivationViewController: UIViewController
|
||||
default:
|
||||
print("Invalid alarm type")
|
||||
}
|
||||
|
||||
alarmStarted = true
|
||||
}
|
||||
|
||||
func initFactorProblem()
|
||||
@@ -167,5 +170,6 @@ class AlarmActivationViewController: UIViewController
|
||||
timer?.invalidate()
|
||||
print("Alarm solved")
|
||||
dismiss(animated: true, completion: nil)
|
||||
alarmStarted = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,9 +71,9 @@ class AlarmActivator: UITabBarController
|
||||
|
||||
alarms.localSave()
|
||||
self.alarm = alarm
|
||||
// Segue
|
||||
//NSLog(JSON.stringify(alarm)!)
|
||||
performSegue(withIdentifier: "activate-alarm", sender: alarm)
|
||||
|
||||
// Avoid starting duplicate alarms
|
||||
if !alarmStarted { performSegue(withIdentifier: "activate-alarm", sender: alarm) }
|
||||
}
|
||||
|
||||
@IBSegueAction func sendAlarm(_ coder: NSCoder) -> AlarmActivationViewController?
|
||||
|
||||
Reference in New Issue
Block a user