Commit a9e4a13e43d74c5cd700da5373ab56cb2128c75e

Authored by yanglingyu
1 parent 80d5b69b

添加修改通知

CNLiveVideoClassifyKit/Classes/SearchView/Model/CNWitnessSearchModel.h
@@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
33 @interface CNToolMessageModel : NSObject 33 @interface CNToolMessageModel : NSObject
34 @property (nonatomic, assign)NSInteger commentsNum; 34 @property (nonatomic, assign)NSInteger commentsNum;
35 @property (nonatomic, strong)NSArray * commentList; 35 @property (nonatomic, strong)NSArray * commentList;
36 -@property (nonatomic, copy)NSString *collectioned; 36 +@property (nonatomic, assign) BOOL collectioned;
37 @property (nonatomic, strong)NSArray * likeList; 37 @property (nonatomic, strong)NSArray * likeList;
38 @property (nonatomic, assign)BOOL liked; 38 @property (nonatomic, assign)BOOL liked;
39 @property (nonatomic, assign)NSInteger likesNum; 39 @property (nonatomic, assign)NSInteger likesNum;
CNLiveVideoClassifyKit/Classes/SearchView/ViewController/CNWitnessSearchDetailController.m
@@ -12,7 +12,26 @@ @@ -12,7 +12,26 @@
12 #import "CNWitnessSearchModel.h" 12 #import "CNWitnessSearchModel.h"
13 #import "CNCollectionViewLayout.h" 13 #import "CNCollectionViewLayout.h"
14 #import "CNLiveListManager.h" 14 #import "CNLiveListManager.h"
15 - 15 +//关注
  16 +#ifndef WjjAttentionUserStatusToJSNotification
  17 +#define WjjAttentionUserStatusToJSNotification @"WjjAttentionUserStatusToJSNotification"
  18 +#endif
  19 +//评论
  20 +#ifndef WjjWitnessCommentStatusNotification
  21 +#define WjjWitnessCommentStatusNotification @"WjjWitnessCommentStatusNotification"
  22 +#endif
  23 +//分享
  24 +#ifndef WjjWitnessShareNotification
  25 +#define WjjWitnessShareNotification @"WjjWitnessShareNotification"
  26 +#endif
  27 +//点赞
  28 +#ifndef WjjWitnessLikeStatusNotification
  29 +#define WjjWitnessLikeStatusNotification @"WjjWitnessLikeStatusNotification"
  30 +#endif
  31 +//收藏
  32 +#ifndef WjjWitnessCollectStatusNotification
  33 +#define WjjWitnessCollectStatusNotification @"WjjWitnessCollectStatusNotification"
  34 +#endif
16 static NSString *const CNWitnessSearchVideoCellID = @"CNWitnessSearchVideoCell"; 35 static NSString *const CNWitnessSearchVideoCellID = @"CNWitnessSearchVideoCell";
17 static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell"; 36 static NSString *const CNWitnessSearchPersonCellID = @"CNWitnessSearchPersonCell";
18 @interface CNWitnessSearchDetailController ()<UICollectionViewDelegate,UICollectionViewDataSource,CNWaterFallLayoutDelegate,UIGestureRecognizerDelegate> 37 @interface CNWitnessSearchDetailController ()<UICollectionViewDelegate,UICollectionViewDataSource,CNWaterFallLayoutDelegate,UIGestureRecognizerDelegate>
@@ -103,7 +122,17 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell @@ -103,7 +122,17 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell
103 [self.view addGestureRecognizer:pan]; 122 [self.view addGestureRecognizer:pan];
104 } 123 }
105 if (self.type == CNWitnessSearchDetailTypeVideo) { 124 if (self.type == CNWitnessSearchDetailTypeVideo) {
  125 +
  126 + //点赞
106 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoChangeWithParam:) name:@"WjjWitnessLikeStatusNotification" object:nil]; 127 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoChangeWithParam:) name:@"WjjWitnessLikeStatusNotification" object:nil];
  128 + //关注
  129 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoFocuseChange:) name:@"WjjAttentionUserStatusToJSNotification" object:nil];
  130 + //评论
  131 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoCommentsChange:) name:WjjWitnessCommentStatusNotification object:nil];
  132 + //分享
  133 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoShareChange:) name:WjjWitnessShareNotification object:nil];
  134 + //收藏
  135 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoCollectChange:) name:WjjWitnessCollectStatusNotification object:nil];
107 }else{ 136 }else{
108 [[CNLiveListManager shareListManager] addObserver:self forKeyPath:@"personMessage" options:NSKeyValueObservingOptionNew context:NULL]; 137 [[CNLiveListManager shareListManager] addObserver:self forKeyPath:@"personMessage" options:NSKeyValueObservingOptionNew context:NULL];
109 } 138 }
@@ -135,6 +164,45 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell @@ -135,6 +164,45 @@ static NSString *const CNWitnessSearchPersonCellID = @&quot;CNWitnessSearchPersonCell
135 } 164 }
136 } 165 }
137 } 166 }
  167 +- (void)videoCollectChange:(NSNotification *)noti{
  168 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  169 + if ([self.videoIDArray containsObject:pid]) {
  170 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  171 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  172 + model.tool.shareNum += 1;
  173 + }
  174 +}
  175 +- (void)videoShareChange:(NSNotification *)noti{
  176 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  177 + if ([self.videoIDArray containsObject:pid]) {
  178 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  179 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  180 + NSString *selected = [noti.userInfo objectForKey:@"selected"];
  181 + model.tool.collectioned = [selected isEqualToString:@"true"];
  182 + if (model.tool.collectioned) {
  183 + model.tool.collectionNum += 1;
  184 + }else{
  185 + model.tool.collectionNum -= 1;
  186 + }
  187 + }
  188 +}
  189 +- (void)videoCommentsChange:(NSNotification *)noti{
  190 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  191 + if ([self.videoIDArray containsObject:pid]) {
  192 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  193 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  194 + model.tool.commentsNum += 1;
  195 + }
  196 +}
  197 +- (void)videoFocuseChange:(NSNotification *)noti{
  198 + NSString *pid = [noti.userInfo objectForKey:@"contentId"];
  199 + if ([self.videoIDArray containsObject:pid]) {
  200 + NSInteger index = [self.videoIDArray indexOfObject:pid];
  201 + CNWitnessSearchDetailModel *model = self.dataSource[index];
  202 + NSString *focused = [noti.userInfo objectForKey:@"focused"];
  203 + model.icon.focused = [focused isEqualToString:@"true"];
  204 + }
  205 +}
138 - (void)videoChangeWithParam:(NSNotification *)noti{ 206 - (void)videoChangeWithParam:(NSNotification *)noti{
139 NSString *pid = [noti.userInfo objectForKey:@"contentId"]; 207 NSString *pid = [noti.userInfo objectForKey:@"contentId"];
140 if ([self.videoIDArray containsObject:pid]) { 208 if ([self.videoIDArray containsObject:pid]) {