/
CountlyViewData.m
57 lines (46 loc) · 1.09 KB
/
CountlyViewData.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// CountlyViewData.m
//
// This code is provided under the MIT License.
//
// Please visit www.count.ly for more information.
#import "CountlyViewData.h"
#import "CountlyCommon.h"
@implementation CountlyViewData
- (instancetype)initWithID:(NSString *)viewID viewName:(NSString *)viewName
{
if (self = [super init])
{
self.viewID = viewID;
self.viewName = viewName;
self.viewStartTime = CountlyCommon.sharedInstance.uniqueTimestamp;
self.isAutoStoppedView = false;
self.isAutoPaused = false;
}
return self;
}
- (NSTimeInterval)duration
{
NSTimeInterval duration = NSDate.date.timeIntervalSince1970 - self.viewStartTime;
return duration;
}
- (void)autoPauseView
{
if (self.viewStartTime) // To check that view is not paused already manually
{
self.isAutoPaused = true;
}
[self pauseView];
}
- (void)pauseView
{
if (self.viewStartTime)
{
self.viewStartTime = 0;
}
}
- (void)resumeView
{
self.isAutoPaused = false;
self.viewStartTime = CountlyCommon.sharedInstance.uniqueTimestamp;
}
@end