summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2015-04-06 23:03:27 -0500
committerBrad Leege <bleege@gmail.com>2015-04-06 23:03:27 -0500
commit4092e469829e7cc14e946b2ed4e413091bd63b3b (patch)
tree31a55cffe167efbd862fdc185d5fa0f5ba10af25
parent0a2ee766dbe65e3d23d0e5cba79776560ff29275 (diff)
downloadqtlocation-mapboxgl-4092e469829e7cc14e946b2ed4e413091bd63b3b.tar.gz
#1216 - Add pause and resume methods with corresponding isPaused boolean flag property
-rw-r--r--include/mbgl/ios/MGLMapboxEvents.h2
-rw-r--r--platform/ios/MGLMapboxEvents.m21
2 files changed, 23 insertions, 0 deletions
diff --git a/include/mbgl/ios/MGLMapboxEvents.h b/include/mbgl/ios/MGLMapboxEvents.h
index e51371368d..2af3d8b168 100644
--- a/include/mbgl/ios/MGLMapboxEvents.h
+++ b/include/mbgl/ios/MGLMapboxEvents.h
@@ -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
diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m
index 2dfecbd778..593a983904 100644
--- a/platform/ios/MGLMapboxEvents.m
+++ b/platform/ios/MGLMapboxEvents.m
@@ -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.
//