mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-10 17:08:39 +00:00
* allow multiple instances of currency and weather widgets (different schedulers for one type widget)
This commit is contained in:
parent
8bccbf3834
commit
1e2043ebda
@ -10,7 +10,7 @@ import Cocoa
|
||||
import CoreLocation
|
||||
|
||||
class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
private let activity = NSBackgroundActivityScheduler(identifier: "com.toxblh.mtmr.currency.updatecheck")
|
||||
private let activity: NSBackgroundActivityScheduler
|
||||
private var prefix: String
|
||||
private var from: String
|
||||
private var to: String
|
||||
@ -37,6 +37,7 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
]
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: String, to: String, onTap: @escaping () -> (), onLongTap: @escaping () -> ()) {
|
||||
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
||||
activity.interval = interval
|
||||
self.from = from
|
||||
self.to = to
|
||||
@ -71,7 +72,6 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
if error == nil {
|
||||
do {
|
||||
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! [String : AnyObject]
|
||||
// print(json)
|
||||
var value: Float32!
|
||||
|
||||
if let data_array = json["data"] as? [String : AnyObject] {
|
||||
|
||||
@ -10,7 +10,7 @@ import Cocoa
|
||||
import CoreLocation
|
||||
|
||||
class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
||||
private let activity = NSBackgroundActivityScheduler(identifier: "com.toxblh.mtmr.weather.updatecheck")
|
||||
private let activity: NSBackgroundActivityScheduler
|
||||
private var units: String
|
||||
private var api_key: String
|
||||
private var units_str = "°F"
|
||||
@ -23,6 +23,7 @@ class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
||||
private var manager:CLLocationManager!
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, units: String, api_key: String, icon_type: String? = "text", onTap: @escaping () -> (), onLongTap: @escaping () -> ()) {
|
||||
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
||||
activity.interval = interval
|
||||
self.units = units
|
||||
self.api_key = api_key
|
||||
|
||||
Loading…
Reference in New Issue
Block a user