#1216 - Add pause and resume methods with corresponding isPaused boolean flag property
This commit is contained in:
@@ -29,6 +29,8 @@ extern NSString *const MGLEventGestureRotateStart;
|
||||
+ (void) setToken:(NSString *)token;
|
||||
+ (void) setAppName:(NSString *)appName;
|
||||
+ (void) setAppVersion:(NSString *)appVersion;
|
||||
+ (void) pauseMetricsCollection;
|
||||
+ (void) resumeMetricsCollection;
|
||||
|
||||
// You can call this method from any thread. Significant work will
|
||||
// be dispatched to a low-priority background queue and all
|
||||
|
||||
@@ -71,6 +71,11 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
|
||||
@property (atomic) NSDateFormatter *rfc3339DateFormatter;
|
||||
@property (atomic) CGFloat scale;
|
||||
|
||||
|
||||
// The isPaused state tracker is only ever accessed from the main thread.
|
||||
//
|
||||
@property (nonatomic) BOOL isPaused;
|
||||
|
||||
// The timer is only ever accessed from the main thread.
|
||||
//
|
||||
@property (nonatomic) NSTimer *timer;
|
||||
@@ -168,6 +173,8 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
|
||||
// Clear Any System TimeZone Cache
|
||||
[NSTimeZone resetSystemTimeZone];
|
||||
[_rfc3339DateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
|
||||
|
||||
_isPaused = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -219,6 +226,20 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
|
||||
[MGLMapboxEvents sharedManager].appVersion = appVersion;
|
||||
}
|
||||
|
||||
// Must be called from the main thread.
|
||||
//
|
||||
+ (void) pauseMetricsCollection {
|
||||
assert([[NSThread currentThread] isMainThread]);
|
||||
[MGLMapboxEvents sharedManager].isPaused = YES;
|
||||
}
|
||||
|
||||
// Must be called from the main thread.
|
||||
//
|
||||
+ (void) resumeMetricsCollection {
|
||||
assert([[NSThread currentThread] isMainThread]);
|
||||
[MGLMapboxEvents sharedManager].isPaused = NO;
|
||||
}
|
||||
|
||||
// Can be called from any thread. Can be called rapidly from
|
||||
// the UI thread, so performance is paramount.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user