Commit 7fefbc80 by Sarkizz

调整定位逻辑

parent e56bd550
...@@ -2,7 +2,7 @@ Pod::Spec.new do |s| ...@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
# 名称,pod search 搜索的关键词,注意这里一定要和.podspec的名称一样,否则报错 # 名称,pod search 搜索的关键词,注意这里一定要和.podspec的名称一样,否则报错
s.name = "MRFramework" s.name = "MRFramework"
# 版本号/库原代码的版本 # 版本号/库原代码的版本
s.version = "0.0.20" s.version = "0.0.21"
# 简介 # 简介
s.summary = "迈动工具库" s.summary = "迈动工具库"
......
...@@ -19,6 +19,7 @@ public class MRLocation: NSObject { ...@@ -19,6 +19,7 @@ public class MRLocation: NSObject {
/// 定位类型 /// 定位类型
public enum LocationType { public enum LocationType {
case none
case system case system
} }
...@@ -45,7 +46,7 @@ public class MRLocation: NSObject { ...@@ -45,7 +46,7 @@ public class MRLocation: NSObject {
let manager = CLLocationManager() let manager = CLLocationManager()
return manager return manager
}() }()
private var locationType: LocationType = .system { private var locationType: LocationType = .none {
didSet { didSet {
locationTypeDidChange() locationTypeDidChange()
} }
...@@ -54,9 +55,12 @@ public class MRLocation: NSObject { ...@@ -54,9 +55,12 @@ public class MRLocation: NSObject {
private var callbacks = [LocationCallback]() private var callbacks = [LocationCallback]()
private var stayCallbacks = [LocationCallback]() private var stayCallbacks = [LocationCallback]()
override init() {}
public convenience init(type: LocationType = .system) { public convenience init(type: LocationType = .system) {
self.init() self.init()
locationType = type locationType = type
locationTypeDidChange()
} }
} }
...@@ -84,7 +88,8 @@ extension MRLocation { ...@@ -84,7 +88,8 @@ extension MRLocation {
if !isEnable { if !isEnable {
return return
} }
let isStartLocating = authorization?(CLLocationManager.authorizationStatus()) ?? true let authorizate = authorization?(CLLocationManager.authorizationStatus())
let isStartLocating = authorizate ?? true
if isStartLocating { if isStartLocating {
/// 存储回调 /// 存储回调
if let finish = finish { if let finish = finish {
...@@ -102,6 +107,8 @@ extension MRLocation { ...@@ -102,6 +107,8 @@ extension MRLocation {
systemLocation.stopUpdatingLocation() systemLocation.stopUpdatingLocation()
systemLocation.startUpdatingLocation() systemLocation.startUpdatingLocation()
_status = .locating _status = .locating
default:
break
} }
} }
} }
...@@ -115,6 +122,8 @@ extension MRLocation { ...@@ -115,6 +122,8 @@ extension MRLocation {
switch locationType { switch locationType {
case .system: case .system:
systemLocation.stopUpdatingLocation() systemLocation.stopUpdatingLocation()
default:
break
} }
} }
} }
...@@ -125,6 +134,8 @@ extension MRLocation { ...@@ -125,6 +134,8 @@ extension MRLocation {
switch locationType { switch locationType {
case .system: case .system:
setupSystemLocation() setupSystemLocation()
default:
break
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment