Turned class methods into instance methods
Avoids unnecessary steps to access singletons. Now `MGLMapboxEvents` and `MGLMetricsLocationManager` instances can message themselves directly.
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
// These methods can be called from any thread.
|
||||
//
|
||||
+ (instancetype)sharedManager;
|
||||
+ (void) startUpdatingLocation;
|
||||
+ (void) stopUpdatingLocation;
|
||||
+ (void) startMonitoringVisits;
|
||||
+ (void) stopMonitoringVisits;
|
||||
- (void) startUpdatingLocation;
|
||||
- (void) stopUpdatingLocation;
|
||||
- (void) startMonitoringVisits;
|
||||
- (void) stopMonitoringVisits;
|
||||
|
||||
@end
|
||||
|
||||
@@ -266,28 +266,38 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
|
||||
[MGLMapboxEvents sharedManager].appBuildNumber = appBuildNumber;
|
||||
}
|
||||
|
||||
// Must be called from the main thread.
|
||||
//
|
||||
+ (void) pauseMetricsCollection {
|
||||
MGLAssertIsMainThread();
|
||||
if ([MGLMapboxEvents sharedManager].paused) {
|
||||
return;
|
||||
}
|
||||
[MGLMapboxEvents sharedManager].paused = YES;
|
||||
[MGLMetricsLocationManager stopUpdatingLocation];
|
||||
[MGLMetricsLocationManager stopMonitoringVisits];
|
||||
+ (void)pauseMetricsCollection {
|
||||
[[MGLMapboxEvents sharedManager] pauseMetricsCollection];
|
||||
}
|
||||
|
||||
// Must be called from the main thread.
|
||||
//
|
||||
+ (void) resumeMetricsCollection {
|
||||
- (void)pauseMetricsCollection {
|
||||
MGLAssertIsMainThread();
|
||||
if (![MGLMapboxEvents sharedManager].paused) {
|
||||
if (self.paused) {
|
||||
return;
|
||||
}
|
||||
[MGLMapboxEvents sharedManager].paused = NO;
|
||||
[MGLMetricsLocationManager startUpdatingLocation];
|
||||
[MGLMetricsLocationManager startMonitoringVisits];
|
||||
self.paused = YES;
|
||||
MGLMetricsLocationManager *sharedLocationManager = [MGLMetricsLocationManager sharedManager];
|
||||
[sharedLocationManager stopUpdatingLocation];
|
||||
[sharedLocationManager stopMonitoringVisits];
|
||||
}
|
||||
|
||||
+ (void)resumeMetricsCollection {
|
||||
[[MGLMapboxEvents sharedManager] resumeMetricsCollection];
|
||||
}
|
||||
|
||||
// Must be called from the main thread.
|
||||
//
|
||||
- (void)resumeMetricsCollection {
|
||||
MGLAssertIsMainThread();
|
||||
if (!self.isPaused) {
|
||||
return;
|
||||
}
|
||||
self.paused = NO;
|
||||
MGLMetricsLocationManager *sharedLocationManager = [MGLMetricsLocationManager sharedManager];
|
||||
[sharedLocationManager startUpdatingLocation];
|
||||
[sharedLocationManager startMonitoringVisits];
|
||||
}
|
||||
|
||||
// Can be called from any thread. Can be called rapidly from
|
||||
|
||||
@@ -39,24 +39,20 @@
|
||||
return sharedManager;
|
||||
}
|
||||
|
||||
+ (void) startUpdatingLocation {
|
||||
[[MGLMetricsLocationManager sharedManager].locationManager startUpdatingLocation];
|
||||
- (void)startUpdatingLocation {
|
||||
[self.locationManager startUpdatingLocation];
|
||||
}
|
||||
|
||||
+ (void) stopUpdatingLocation {
|
||||
[[MGLMetricsLocationManager sharedManager].locationManager stopUpdatingLocation];
|
||||
- (void)stopUpdatingLocation {
|
||||
[self.locationManager stopUpdatingLocation];
|
||||
}
|
||||
|
||||
+ (void) startMonitoringVisits {
|
||||
if ([[MGLMetricsLocationManager sharedManager].locationManager respondsToSelector:@selector(startMonitoringVisits)]) {
|
||||
[[MGLMetricsLocationManager sharedManager].locationManager startMonitoringVisits];
|
||||
}
|
||||
- (void)startMonitoringVisits {
|
||||
[self.locationManager startMonitoringVisits];
|
||||
}
|
||||
|
||||
+ (void) stopMonitoringVisits {
|
||||
if ([[MGLMetricsLocationManager sharedManager].locationManager respondsToSelector:@selector(stopMonitoringVisits)]) {
|
||||
[[MGLMetricsLocationManager sharedManager].locationManager stopMonitoringVisits];
|
||||
}
|
||||
- (void)stopMonitoringVisits {
|
||||
[self.locationManager stopMonitoringVisits];
|
||||
}
|
||||
|
||||
#pragma mark CLLocationManagerDelegate
|
||||
@@ -96,21 +92,21 @@
|
||||
break;
|
||||
case kCLAuthorizationStatusDenied:
|
||||
newStatus = @"User Explcitly Denied";
|
||||
[MGLMetricsLocationManager stopUpdatingLocation];
|
||||
[MGLMetricsLocationManager stopMonitoringVisits];
|
||||
[self stopUpdatingLocation];
|
||||
[self stopMonitoringVisits];
|
||||
break;
|
||||
case kCLAuthorizationStatusAuthorized:
|
||||
newStatus = @"User Has Authorized / Authorized Always";
|
||||
[MGLMetricsLocationManager startUpdatingLocation];
|
||||
[MGLMetricsLocationManager startMonitoringVisits];
|
||||
[self startUpdatingLocation];
|
||||
[self startMonitoringVisits];
|
||||
break;
|
||||
// case kCLAuthorizationStatusAuthorizedAlways:
|
||||
// newStatus = @"Not Determined";
|
||||
// break;
|
||||
// case kCLAuthorizationStatusAuthorizedAlways:
|
||||
// newStatus = @"Not Determined";
|
||||
// break;
|
||||
case kCLAuthorizationStatusAuthorizedWhenInUse:
|
||||
newStatus = @"User Has Authorized When In Use Only";
|
||||
[MGLMetricsLocationManager startUpdatingLocation];
|
||||
[MGLMetricsLocationManager startMonitoringVisits];
|
||||
[self startUpdatingLocation];
|
||||
[self startMonitoringVisits];
|
||||
break;
|
||||
default:
|
||||
newStatus = @"Unknown";
|
||||
|
||||
Reference in New Issue
Block a user