Skip to content

Commit

Permalink
Merged in 477_FloatBarTwice (pull request #3)
Browse files Browse the repository at this point in the history
Add property to let customer set a view controller not behave StreetHawk action even it inherits these base vc.

Approved-by: jagguli <steven@streethawk.co>
Approved-by: ChristineXYS <christine@streethawk.com>
  • Loading branch information
ChristineXYS committed May 5, 2017
2 parents 2d10765 + 5af34aa commit 855bb43
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 15 deletions.
18 changes: 18 additions & 0 deletions StreetHawk/Classes/Core/Publish/SHBaseViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,38 @@
*/
@interface StreetHawkBaseViewController : UIViewController <ISHDeepLinking>

/**
Some customer view controller may be inherited not in purpose (such as base vc do inherit).
Use this property to exclude them from being treated as StreetHawk behavior vc.
*/
@property (nonatomic) BOOL excludeBehavior;

@end

/**
Base class for all view controller inherit from UITableViewController. It sends logs when enter/exit this VC.
*/
@interface StreetHawkBaseTableViewController : UITableViewController <ISHDeepLinking>

/**
Some customer view controller may be inherited not in purpose (such as base vc do inherit).
Use this property to exclude them from being treated as StreetHawk behavior vc.
*/
@property (nonatomic) BOOL excludeBehavior;

@end

/**
Base class for all view controller inherit from UICollectionViewController. It sends logs when enter/exit this VC.
*/
@interface StreetHawkBaseCollectionViewController : UICollectionViewController <ISHDeepLinking>

/**
Some customer view controller may be inherited not in purpose (such as base vc do inherit).
Use this property to exclude them from being treated as StreetHawk behavior vc.
*/
@property (nonatomic) BOOL excludeBehavior;

@end

/**
Expand Down
138 changes: 123 additions & 15 deletions StreetHawk/Classes/Core/Publish/SHBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,41 @@ - (NSString *)refinePageName

@implementation StreetHawkBaseViewController

- (id)init
{
if (self = [super init])
{
self.excludeBehavior = NO;
}
return self;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.excludeBehavior = NO;
}
return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder])
{
self.excludeBehavior = NO;
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
if ([self respondsToSelector:@selector(displayDeepLinkingToUI)])
{
[self performSelector:@selector(displayDeepLinkingToUI)];
}
if (!shIsSDKViewController(self)) //Not show tip and super tag for SDK vc
if (!self.excludeBehavior && !shIsSDKViewController(self)) //Not show tip and super tag for SDK vc
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_ShowTip_Notification" object:nil userInfo:@{@"vc": self}];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_SuperTag_Notification" object:nil userInfo:@{@"vc": self}];
Expand All @@ -70,8 +97,11 @@ - (void)viewDidLoad
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSUserDefaults standardUserDefaults] setObject:self.class.description forKey:@"ENTERBAK_PAGE_HISTORY"];
[[NSUserDefaults standardUserDefaults] synchronize];
if (!self.excludeBehavior && !shIsSDKViewController(self))
{
[[NSUserDefaults standardUserDefaults] setObject:self.class.description forKey:@"ENTERBAK_PAGE_HISTORY"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}

//tricky: Here must use `viewDidAppear` and `viewWillDisappear`.
Expand All @@ -81,7 +111,7 @@ - (void)viewWillAppear:(BOOL)animated
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (!shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
if (!self.excludeBehavior && !shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
{
[StreetHawk shNotifyPageEnter:[self.class.description refinePageName]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_EnterVC_Notification" object:nil userInfo:@{@"vc": self}];
Expand All @@ -92,7 +122,7 @@ - (void)viewDidAppear:(BOOL)animated
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if (!shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
if (!self.excludeBehavior && !shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
{
[StreetHawk shNotifyPageExit:[self.class.description refinePageName]];

Expand All @@ -105,14 +135,50 @@ - (void)viewWillDisappear:(BOOL)animated

@implementation StreetHawkBaseTableViewController

- (id)init
{
if (self = [super init])
{
self.excludeBehavior = NO;
}
return self;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.excludeBehavior = NO;
}
return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder])
{
self.excludeBehavior = NO;
}
return self;
}

- (id)initWithStyle:(UITableViewStyle)style
{
if (self = [super initWithStyle:style])
{
self.excludeBehavior = NO;
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
if ([self respondsToSelector:@selector(displayDeepLinkingToUI)])
{
[self performSelector:@selector(displayDeepLinkingToUI)];
}
if (!shIsSDKViewController(self)) //Not show tip and super tag for SDK vc
if (!self.excludeBehavior && !shIsSDKViewController(self)) //Not show tip and super tag for SDK vc
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_ShowTip_Notification" object:nil userInfo:@{@"vc": self}];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_SuperTag_Notification" object:nil userInfo:@{@"vc": self}];
Expand All @@ -122,14 +188,17 @@ - (void)viewDidLoad
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSUserDefaults standardUserDefaults] setObject:self.class.description forKey:@"ENTERBAK_PAGE_HISTORY"];
[[NSUserDefaults standardUserDefaults] synchronize];
if (!self.excludeBehavior && !shIsSDKViewController(self))
{
[[NSUserDefaults standardUserDefaults] setObject:self.class.description forKey:@"ENTERBAK_PAGE_HISTORY"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (!shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
if (!self.excludeBehavior && !shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
{
[StreetHawk shNotifyPageEnter:[self.class.description refinePageName]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_EnterVC_Notification" object:nil userInfo:@{@"vc": self}];
Expand All @@ -140,7 +209,7 @@ - (void)viewDidAppear:(BOOL)animated
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if (!shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
if (!self.excludeBehavior && !shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
{
[StreetHawk shNotifyPageExit:[self.class.description refinePageName]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_ForceDismissTip_Notification" object:nil userInfo:@{@"vc": self}];
Expand All @@ -152,14 +221,50 @@ - (void)viewWillDisappear:(BOOL)animated

@implementation StreetHawkBaseCollectionViewController

- (id)init
{
if (self = [super init])
{
self.excludeBehavior = NO;
}
return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder])
{
self.excludeBehavior = NO;
}
return self;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.excludeBehavior = NO;
}
return self;
}

- (id)initWithCollectionViewLayout:(UICollectionViewLayout *)layout
{
if (self = [super initWithCollectionViewLayout:layout])
{
self.excludeBehavior = NO;
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
if ([self respondsToSelector:@selector(displayDeepLinkingToUI)])
{
[self performSelector:@selector(displayDeepLinkingToUI)];
}
if (!shIsSDKViewController(self)) //Not show tip and super tag for SDK vc
if (!self.excludeBehavior && !shIsSDKViewController(self)) //Not show tip and super tag for SDK vc
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_ShowTip_Notification" object:nil userInfo:@{@"vc": self}];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_SuperTag_Notification" object:nil userInfo:@{@"vc": self}];
Expand All @@ -169,14 +274,17 @@ - (void)viewDidLoad
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSUserDefaults standardUserDefaults] setObject:self.class.description forKey:@"ENTERBAK_PAGE_HISTORY"];
[[NSUserDefaults standardUserDefaults] synchronize];
if (!self.excludeBehavior && !shIsSDKViewController(self))
{
[[NSUserDefaults standardUserDefaults] setObject:self.class.description forKey:@"ENTERBAK_PAGE_HISTORY"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (!shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
if (!self.excludeBehavior && !shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
{
[StreetHawk shNotifyPageEnter:[self.class.description refinePageName]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_EnterVC_Notification" object:nil userInfo:@{@"vc": self}];
Expand All @@ -187,7 +295,7 @@ - (void)viewDidAppear:(BOOL)animated
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if (!shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
if (!self.excludeBehavior && !shIsSDKViewController(self)) //several internal used vc not need log, such as SHFeedbackViewController, SHSlideWebViewController (it calls appear even not show).
{
[StreetHawk shNotifyPageExit:[self.class.description refinePageName]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SH_PointziBridge_ForceDismissTip_Notification" object:nil userInfo:@{@"vc": self}];
Expand Down

0 comments on commit 855bb43

Please sign in to comment.