Commit 40722ba0bbeac36ab3913416aafd6f9838597c4e
1 parent
5f02f0e9
no message
Showing
8 changed files
with
60 additions
and
94 deletions
CNLiveMineModule/Classes/UserInfo/CNLiveInfoUpdateController.h
| @@ -6,20 +6,12 @@ | @@ -6,20 +6,12 @@ | ||
| 6 | // Copyright (c) 2019 153993236@qq.com. All rights reserved. | 6 | // Copyright (c) 2019 153993236@qq.com. All rights reserved. |
| 7 | // | 7 | // |
| 8 | 8 | ||
| 9 | -#import <UIKit/UIKit.h> | ||
| 10 | -#import "CNLiveUserInfoModel.h" | ||
| 11 | #import "CNCommonViewController.h" | 9 | #import "CNCommonViewController.h" |
| 12 | 10 | ||
| 13 | NS_ASSUME_NONNULL_BEGIN | 11 | NS_ASSUME_NONNULL_BEGIN |
| 14 | -@class CNLiveInfoUpdateController; | ||
| 15 | - | ||
| 16 | -@protocol CNLiveInfoUpdateDelegate <NSObject> | ||
| 17 | -- (void)updateSuccess:(CNLiveUserInfoDataType)dataType info:(NSString *)info; | ||
| 18 | - | ||
| 19 | -@end | 12 | +@class CNLiveUserInfoModel; |
| 20 | 13 | ||
| 21 | @interface CNLiveInfoUpdateController : CNCommonViewController | 14 | @interface CNLiveInfoUpdateController : CNCommonViewController |
| 22 | -@property (nonatomic, weak) id<CNLiveInfoUpdateDelegate> delegate; | ||
| 23 | 15 | ||
| 24 | /** | 16 | /** |
| 25 | * @abstract 对象方法 初始化方法 | 17 | * @abstract 对象方法 初始化方法 |
CNLiveMineModule/Classes/UserInfo/CNLiveInfoUpdateController.m
| @@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
| 29 | #import "CNLiveGoldWhereaboutsView.h" | 29 | #import "CNLiveGoldWhereaboutsView.h" |
| 30 | #import "CNLiveCategory.h" | 30 | #import "CNLiveCategory.h" |
| 31 | 31 | ||
| 32 | -#import "CNLiveUserInfoModel.h" | 32 | +//#import "CNLiveUserInfoModel.h" |
| 33 | #import "CNLiveUserInfoNotification.h" | 33 | #import "CNLiveUserInfoNotification.h" |
| 34 | #import "CNLiveUserInfoNavigationBar.h" | 34 | #import "CNLiveUserInfoNavigationBar.h" |
| 35 | 35 | ||
| @@ -594,10 +594,8 @@ static const CGFloat timeValue = 1.5; | @@ -594,10 +594,8 @@ static const CGFloat timeValue = 1.5; | ||
| 594 | 594 | ||
| 595 | #pragma mark - 更新提示 | 595 | #pragma mark - 更新提示 |
| 596 | - (void)showSucceed:(NSString *)info{ | 596 | - (void)showSucceed:(NSString *)info{ |
| 597 | - // 跟新本地数据 | ||
| 598 | - if (self.delegate && [self.delegate respondsToSelector:@selector(updateSuccess:info:)]) { | ||
| 599 | - [self.delegate updateSuccess:self.model.dataType info:info]; | ||
| 600 | - } | 597 | + [CNLiveUserInfoNotification postUserInfoUpdateNotificationType:self.model.dataType info:info]; |
| 598 | + | ||
| 601 | [[IMAPlatform sharedInstance].host asyncProfile]; | 599 | [[IMAPlatform sharedInstance].host asyncProfile]; |
| 602 | [QMUITips hideAllToastInView:self.view animated:YES]; | 600 | [QMUITips hideAllToastInView:self.view animated:YES]; |
| 603 | self.navigationBar.right.userInteractionEnabled = YES; | 601 | self.navigationBar.right.userInteractionEnabled = YES; |
| @@ -606,6 +604,7 @@ static const CGFloat timeValue = 1.5; | @@ -606,6 +604,7 @@ static const CGFloat timeValue = 1.5; | ||
| 606 | [QMUITips hideAllToastInView:self.view animated:YES]; | 604 | [QMUITips hideAllToastInView:self.view animated:YES]; |
| 607 | [self goBack]; | 605 | [self goBack]; |
| 608 | }); | 606 | }); |
| 607 | + | ||
| 609 | } | 608 | } |
| 610 | - (void)showError:(NSString *)text{ | 609 | - (void)showError:(NSString *)text{ |
| 611 | self.navigationBar.right.userInteractionEnabled = YES; | 610 | self.navigationBar.right.userInteractionEnabled = YES; |
| @@ -668,7 +667,7 @@ static const CGFloat timeValue = 1.5; | @@ -668,7 +667,7 @@ static const CGFloat timeValue = 1.5; | ||
| 668 | [_contentView addSubview:self.textField]; | 667 | [_contentView addSubview:self.textField]; |
| 669 | self.textField.placeholder = @"请输入昵称"; | 668 | self.textField.placeholder = @"请输入昵称"; |
| 670 | 669 | ||
| 671 | - self.textField.text = self.model.content; | 670 | + self.textField.text = self.model.info; |
| 672 | } | 671 | } |
| 673 | break; | 672 | break; |
| 674 | case CNLiveUserInfoDataTypeAddress: | 673 | case CNLiveUserInfoDataTypeAddress: |
| @@ -678,7 +677,7 @@ static const CGFloat timeValue = 1.5; | @@ -678,7 +677,7 @@ static const CGFloat timeValue = 1.5; | ||
| 678 | [_contentView addSubview:self.textField]; | 677 | [_contentView addSubview:self.textField]; |
| 679 | self.textField.placeholder = @"请输入你所在的地区"; | 678 | self.textField.placeholder = @"请输入你所在的地区"; |
| 680 | 679 | ||
| 681 | - self.textField.text = self.model.content; | 680 | + self.textField.text = self.model.info; |
| 682 | } | 681 | } |
| 683 | break; | 682 | break; |
| 684 | case CNLiveUserInfoDataTypeGender: | 683 | case CNLiveUserInfoDataTypeGender: |
| @@ -697,7 +696,7 @@ static const CGFloat timeValue = 1.5; | @@ -697,7 +696,7 @@ static const CGFloat timeValue = 1.5; | ||
| 697 | 696 | ||
| 698 | _contentView.frame = CGRectMake(0, NavigationContentTop+margin, SCREEN_WIDTH, 120); | 697 | _contentView.frame = CGRectMake(0, NavigationContentTop+margin, SCREEN_WIDTH, 120); |
| 699 | [_contentView addSubview:self.textView]; | 698 | [_contentView addSubview:self.textView]; |
| 700 | - self.textView.text = self.model.content; | 699 | + self.textView.text = self.model.info; |
| 701 | self.textNum.text = [NSString stringWithFormat:@"%lu",MAX(0,MAX_LIMIT_NUMS - self.textView.text.length)]; | 700 | self.textNum.text = [NSString stringWithFormat:@"%lu",MAX(0,MAX_LIMIT_NUMS - self.textView.text.length)]; |
| 702 | 701 | ||
| 703 | [_contentView addSubview:self.textNum]; | 702 | [_contentView addSubview:self.textNum]; |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoCell.m
| @@ -50,7 +50,7 @@ static const NSInteger margin = 12; | @@ -50,7 +50,7 @@ static const NSInteger margin = 12; | ||
| 50 | _model = model; | 50 | _model = model; |
| 51 | _title.text = model.title; | 51 | _title.text = model.title; |
| 52 | 52 | ||
| 53 | - _content.text = model.content; | 53 | + _content.text = model.info; |
| 54 | 54 | ||
| 55 | if(model.dataType == CNLiveUserInfoDataTypeHead){ | 55 | if(model.dataType == CNLiveUserInfoDataTypeHead){ |
| 56 | _pic.backgroundColor = [UIColor whiteColor]; | 56 | _pic.backgroundColor = [UIColor whiteColor]; |
| @@ -58,15 +58,15 @@ static const NSInteger margin = 12; | @@ -58,15 +58,15 @@ static const NSInteger margin = 12; | ||
| 58 | _pic.layer.masksToBounds = YES; | 58 | _pic.layer.masksToBounds = YES; |
| 59 | _pic.layer.cornerRadius = 5.0; | 59 | _pic.layer.cornerRadius = 5.0; |
| 60 | UIImage *xw_image = [self getImageWithImageName:@"default_avatar_f" bundleName:@"CNLiveMineModule" targetClass:[self class]]; | 60 | UIImage *xw_image = [self getImageWithImageName:@"default_avatar_f" bundleName:@"CNLiveMineModule" targetClass:[self class]]; |
| 61 | - [_pic sd_setImageWithURL:[NSURL URLWithString:model.content] placeholderImage:xw_image]; | 61 | + [_pic sd_setImageWithURL:[NSURL URLWithString:model.info] placeholderImage:xw_image]; |
| 62 | 62 | ||
| 63 | }else if (model.dataType == CNLiveUserInfoDataTypeNickname){ | 63 | }else if (model.dataType == CNLiveUserInfoDataTypeNickname){ |
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | }else if (model.dataType == CNLiveUserInfoDataTypeGender){ | 66 | }else if (model.dataType == CNLiveUserInfoDataTypeGender){ |
| 67 | - if([model.content isEqualToString:@"m"]){ | 67 | + if([model.info isEqualToString:@"m"]){ |
| 68 | _content.text = @"男"; | 68 | _content.text = @"男"; |
| 69 | - }else if([model.content isEqualToString:@"f"]){ | 69 | + }else if([model.info isEqualToString:@"f"]){ |
| 70 | _content.text = @"女"; | 70 | _content.text = @"女"; |
| 71 | }else{ | 71 | }else{ |
| 72 | _content.text = @"未知"; | 72 | _content.text = @"未知"; |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoController.m
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | #import "CNLiveUserInfoNotification.h" | 19 | #import "CNLiveUserInfoNotification.h" |
| 20 | #import "CNLiveUserInfoNavigationBar.h" | 20 | #import "CNLiveUserInfoNavigationBar.h" |
| 21 | 21 | ||
| 22 | -@interface CNLiveUserInfoController ()<UITableViewDelegate, UITableViewDataSource, CNLiveInfoUpdateDelegate, CNLiveUserInfoNavigationBarDelegate>{ | 22 | +@interface CNLiveUserInfoController ()<UITableViewDelegate, UITableViewDataSource, CNLiveUserInfoNavigationBarDelegate>{ |
| 23 | UIImage *_image; | 23 | UIImage *_image; |
| 24 | } | 24 | } |
| 25 | @property (nonatomic, strong) CNLiveUserInfoNavigationBar *navigationBar; | 25 | @property (nonatomic, strong) CNLiveUserInfoNavigationBar *navigationBar; |
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | @"layout":@"2", | 36 | @"layout":@"2", |
| 37 | @"data":@"0", | 37 | @"data":@"0", |
| 38 | @"title":@"头像", | 38 | @"title":@"头像", |
| 39 | - @"content":CNUserShareModel.faceUrl, | 39 | + @"info":CNUserShareModel.faceUrl, |
| 40 | @"height":@"81", | 40 | @"height":@"81", |
| 41 | @"lineHeight":@"0.5" | 41 | @"lineHeight":@"0.5" |
| 42 | }, | 42 | }, |
| @@ -44,7 +44,7 @@ | @@ -44,7 +44,7 @@ | ||
| 44 | @"layout":@"1", | 44 | @"layout":@"1", |
| 45 | @"data":@"1", | 45 | @"data":@"1", |
| 46 | @"title":@"昵称", | 46 | @"title":@"昵称", |
| 47 | - @"content":CNUserShareModel.nickname, | 47 | + @"info":CNUserShareModel.nickname, |
| 48 | @"height":@"51", | 48 | @"height":@"51", |
| 49 | @"lineHeight":@"0.5" | 49 | @"lineHeight":@"0.5" |
| 50 | }, | 50 | }, |
| @@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
| 52 | @"layout":@"1", | 52 | @"layout":@"1", |
| 53 | @"data":@"2", | 53 | @"data":@"2", |
| 54 | @"title":@"性别", | 54 | @"title":@"性别", |
| 55 | - @"content":CNUserShareModel.gender, | 55 | + @"info":CNUserShareModel.gender, |
| 56 | @"height":@"60", | 56 | @"height":@"60", |
| 57 | @"lineHeight":@"10" | 57 | @"lineHeight":@"10" |
| 58 | }, | 58 | }, |
| @@ -60,7 +60,7 @@ | @@ -60,7 +60,7 @@ | ||
| 60 | @"layout":@"2", | 60 | @"layout":@"2", |
| 61 | @"data":@"3", | 61 | @"data":@"3", |
| 62 | @"title":@"二维码", | 62 | @"title":@"二维码", |
| 63 | - @"content":@"二维码", | 63 | + @"info":@"二维码", |
| 64 | @"height":@"51", | 64 | @"height":@"51", |
| 65 | @"lineHeight":@"0.5" | 65 | @"lineHeight":@"0.5" |
| 66 | }, | 66 | }, |
| @@ -68,7 +68,7 @@ | @@ -68,7 +68,7 @@ | ||
| 68 | @"layout":@"1", | 68 | @"layout":@"1", |
| 69 | @"data":@"4", | 69 | @"data":@"4", |
| 70 | @"title":@"地区", | 70 | @"title":@"地区", |
| 71 | - @"content":CNUserShareModel.location, | 71 | + @"info":CNUserShareModel.location, |
| 72 | @"height":@"60", | 72 | @"height":@"60", |
| 73 | @"lineHeight":@"10" | 73 | @"lineHeight":@"10" |
| 74 | }, | 74 | }, |
| @@ -76,7 +76,7 @@ | @@ -76,7 +76,7 @@ | ||
| 76 | @"layout":@"1", | 76 | @"layout":@"1", |
| 77 | @"data":@"5", | 77 | @"data":@"5", |
| 78 | @"title":@"个性签名", | 78 | @"title":@"个性签名", |
| 79 | - @"content":CNUserShareModel.signature?CNUserShareModel.signature:@"懒到没签名!", | 79 | + @"info":CNUserShareModel.signature?CNUserShareModel.signature:@"懒到没签名!", |
| 80 | @"height":@"51", | 80 | @"height":@"51", |
| 81 | @"lineHeight":@"0.5" | 81 | @"lineHeight":@"0.5" |
| 82 | } | 82 | } |
| @@ -104,14 +104,15 @@ | @@ -104,14 +104,15 @@ | ||
| 104 | else { | 104 | else { |
| 105 | self.automaticallyAdjustsScrollViewInsets = NO; | 105 | self.automaticallyAdjustsScrollViewInsets = NO; |
| 106 | } | 106 | } |
| 107 | + [CNLiveUserInfoNotification addUserInfoUpdateObserver:self selector:@selector(userInfoUpdateNotification:)]; | ||
| 108 | + | ||
| 107 | [self createSubViews]; | 109 | [self createSubViews]; |
| 108 | [self loadData]; | 110 | [self loadData]; |
| 109 | 111 | ||
| 110 | } | 112 | } |
| 111 | 113 | ||
| 112 | - (void)dealloc { | 114 | - (void)dealloc { |
| 113 | - | ||
| 114 | - | 115 | + [CNLiveUserInfoNotification removeObserver:self]; |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | - (void)createSubViews { | 118 | - (void)createSubViews { |
| @@ -144,73 +145,45 @@ | @@ -144,73 +145,45 @@ | ||
| 144 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | 145 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ |
| 145 | CNLiveUserInfoModel *model = self.data[indexPath.row]; | 146 | CNLiveUserInfoModel *model = self.data[indexPath.row]; |
| 146 | switch (model.dataType) { | 147 | switch (model.dataType) { |
| 147 | - case CNLiveUserInfoDataTypeHead: | ||
| 148 | - { | ||
| 149 | - CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; | ||
| 150 | - vc.delegate = self; | ||
| 151 | - [self.navigationController pushViewController:vc animated:YES]; | ||
| 152 | - } | ||
| 153 | - break; | ||
| 154 | - case CNLiveUserInfoDataTypeNickname: | ||
| 155 | - { | ||
| 156 | - CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; | ||
| 157 | - vc.delegate = self; | ||
| 158 | - [self.navigationController pushViewController:vc animated:YES]; | ||
| 159 | - } | ||
| 160 | - break; | ||
| 161 | - case CNLiveUserInfoDataTypeGender: | ||
| 162 | - { | ||
| 163 | - CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; | ||
| 164 | - vc.delegate = self; | ||
| 165 | - [self.navigationController pushViewController:vc animated:YES]; | ||
| 166 | - } | ||
| 167 | - break; | ||
| 168 | case CNLiveUserInfoDataTypeCode: | 148 | case CNLiveUserInfoDataTypeCode: |
| 169 | { | 149 | { |
| 170 | id<CNLiveQrCodeServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveQrCodeServiceProtocol)]; | 150 | id<CNLiveQrCodeServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveQrCodeServiceProtocol)]; |
| 171 | [service pushToMyQrCodeController:NO]; | 151 | [service pushToMyQrCodeController:NO]; |
| 172 | } | 152 | } |
| 173 | break; | 153 | break; |
| 174 | - case CNLiveUserInfoDataTypeAddress: | ||
| 175 | - { | ||
| 176 | - CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; | ||
| 177 | - vc.delegate = self; | ||
| 178 | - [self.navigationController pushViewController:vc animated:YES]; | ||
| 179 | - } | ||
| 180 | - break; | ||
| 181 | - case CNLiveUserInfoDataTypeIntroduction: | 154 | + default: |
| 182 | { | 155 | { |
| 183 | CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; | 156 | CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; |
| 184 | - vc.delegate = self; | ||
| 185 | [self.navigationController pushViewController:vc animated:YES]; | 157 | [self.navigationController pushViewController:vc animated:YES]; |
| 186 | } | 158 | } |
| 187 | break; | 159 | break; |
| 188 | - | ||
| 189 | - default: | ||
| 190 | - break; | ||
| 191 | } | 160 | } |
| 192 | } | 161 | } |
| 193 | -#pragma mark - CNLiveInfoUpdateDelegate | ||
| 194 | -- (void)updateSuccess:(CNLiveUserInfoDataType)dataType info:(NSString *)info{ | ||
| 195 | - [self updateDataType:dataType info:info]; | 162 | + |
| 163 | +#pragma mark - CNLiveUserInfoNavigationBarDelegate | ||
| 164 | +- (void)navigationBar:(CNLiveUserInfoNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{ | ||
| 165 | + if ([actionEvents isEqualToString:@"1"]) { | ||
| 166 | + [self goBack]; | ||
| 167 | + } | ||
| 196 | } | 168 | } |
| 197 | 169 | ||
| 198 | -// 更新cell展示信息 | ||
| 199 | -- (void)updateDataType:(CNLiveUserInfoDataType)dataType info:(NSString *)info{ | 170 | +#pragma mark - 监听 |
| 171 | +// 更新用户信息 | ||
| 172 | +- (void)userInfoUpdateNotification:(NSNotification *)noti{ | ||
| 173 | + //使用userInfo处理消息 | ||
| 174 | + NSDictionary *dic = [noti userInfo]; | ||
| 175 | + CNLiveUserInfoDataType dataType = [[dic objectForKey:@"type"] integerValue]; | ||
| 176 | + NSString *info = [dic objectForKey:@"info"]; | ||
| 177 | + | ||
| 178 | + // 更新cell展示信息 | ||
| 200 | for(CNLiveUserInfoModel *model in self.data){ | 179 | for(CNLiveUserInfoModel *model in self.data){ |
| 201 | if(dataType == model.dataType){ | 180 | if(dataType == model.dataType){ |
| 202 | - model.content = info; | 181 | + model.info = info; |
| 203 | break; | 182 | break; |
| 204 | } | 183 | } |
| 205 | } | 184 | } |
| 206 | [self.tableView reloadData]; | 185 | [self.tableView reloadData]; |
| 207 | -} | ||
| 208 | 186 | ||
| 209 | -#pragma mark - CNLiveUserInfoNavigationBarDelegate | ||
| 210 | -- (void)navigationBar:(CNLiveUserInfoNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{ | ||
| 211 | - if ([actionEvents isEqualToString:@"1"]) { | ||
| 212 | - [self goBack]; | ||
| 213 | - } | ||
| 214 | } | 187 | } |
| 215 | 188 | ||
| 216 | #pragma mark - 懒加载 | 189 | #pragma mark - 懒加载 |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoModel.h
| @@ -29,7 +29,7 @@ typedef NS_ENUM(NSInteger, CNLiveUserInfoDataType) { | @@ -29,7 +29,7 @@ typedef NS_ENUM(NSInteger, CNLiveUserInfoDataType) { | ||
| 29 | 29 | ||
| 30 | @interface CNLiveUserInfoModel : NSObject | 30 | @interface CNLiveUserInfoModel : NSObject |
| 31 | @property (nonatomic, copy) NSString *title; | 31 | @property (nonatomic, copy) NSString *title; |
| 32 | -@property (nonatomic, copy) NSString *content; | 32 | +@property (nonatomic, copy) NSString *info; |
| 33 | @property (nonatomic, copy) NSString *layout; | 33 | @property (nonatomic, copy) NSString *layout; |
| 34 | @property (nonatomic, copy) NSString *data; | 34 | @property (nonatomic, copy) NSString *data; |
| 35 | 35 |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoNotification.h
| @@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
| 10 | #import "CNLiveUserInfoModel.h" | 10 | #import "CNLiveUserInfoModel.h" |
| 11 | 11 | ||
| 12 | NS_ASSUME_NONNULL_BEGIN | 12 | NS_ASSUME_NONNULL_BEGIN |
| 13 | +extern NSString * const kCNLiveUserInfoUpdateNotification; | ||
| 13 | 14 | ||
| 14 | @interface CNLiveUserInfoNotification : NSObject | 15 | @interface CNLiveUserInfoNotification : NSObject |
| 15 | + (void)postUserInfoUpdateNotificationType:(CNLiveUserInfoDataType)type info:(id)info; | 16 | + (void)postUserInfoUpdateNotificationType:(CNLiveUserInfoDataType)type info:(id)info; |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoNotification.m
| @@ -9,7 +9,8 @@ | @@ -9,7 +9,8 @@ | ||
| 9 | #import "CNLiveUserInfoNotification.h" | 9 | #import "CNLiveUserInfoNotification.h" |
| 10 | 10 | ||
| 11 | @implementation CNLiveUserInfoNotification | 11 | @implementation CNLiveUserInfoNotification |
| 12 | -static NSString * const kCNLiveUserInfoUpdateNotification = @"CNLiveUserInfoUpdateNotification"; | 12 | + |
| 13 | +NSString * const kCNLiveUserInfoUpdateNotification = @"CNLiveUserInfoUpdateNotification"; | ||
| 13 | 14 | ||
| 14 | + (void)postUserInfoUpdateNotificationType:(CNLiveUserInfoDataType)type info:(id)info{ | 15 | + (void)postUserInfoUpdateNotificationType:(CNLiveUserInfoDataType)type info:(id)info{ |
| 15 | NSDictionary *dic = @{@"type":@(type),@"info":info}; | 16 | NSDictionary *dic = @{@"type":@(type),@"info":info}; |
CNLiveMineModule/Classes/View/CNLiveMineHeaderView.m
| @@ -13,6 +13,7 @@ | @@ -13,6 +13,7 @@ | ||
| 13 | #import "CNLiveCategory.h" | 13 | #import "CNLiveCategory.h" |
| 14 | 14 | ||
| 15 | #import "CNUserInfoManager.h" | 15 | #import "CNUserInfoManager.h" |
| 16 | +#import "CNLiveUserInfoNotification.h" | ||
| 16 | 17 | ||
| 17 | @interface CNLiveMineHeaderView () | 18 | @interface CNLiveMineHeaderView () |
| 18 | @property (nonatomic, strong) UIImageView *bgView; | 19 | @property (nonatomic, strong) UIImageView *bgView; |
| @@ -34,7 +35,7 @@ static const NSInteger margin = 20; | @@ -34,7 +35,7 @@ static const NSInteger margin = 20; | ||
| 34 | if(self){ | 35 | if(self){ |
| 35 | self.userInteractionEnabled = YES; | 36 | self.userInteractionEnabled = YES; |
| 36 | self.backgroundColor = [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1.0]; | 37 | self.backgroundColor = [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1.0]; |
| 37 | -// [XWUserInfoNotification addUserInfoUpdateObserver:self selector:@selector(userInfoUpdateNotification:)]; | 38 | + [CNLiveUserInfoNotification addUserInfoUpdateObserver:self selector:@selector(userInfoUpdateNotification:)]; |
| 38 | [self createSubViews]; | 39 | [self createSubViews]; |
| 39 | } | 40 | } |
| 40 | return self; | 41 | return self; |
| @@ -42,26 +43,25 @@ static const NSInteger margin = 20; | @@ -42,26 +43,25 @@ static const NSInteger margin = 20; | ||
| 42 | // 实现方法 | 43 | // 实现方法 |
| 43 | - (void)userInfoUpdateNotification:(NSNotification *)noti{ | 44 | - (void)userInfoUpdateNotification:(NSNotification *)noti{ |
| 44 | //使用userInfo处理消息 | 45 | //使用userInfo处理消息 |
| 45 | -// NSDictionary *dic = [noti userInfo]; | ||
| 46 | -// XWUserInfoDataType type = [[dic objectForKey:@"type"] integerValue]; | ||
| 47 | -// if(type == XWUserInfoDataTypeHead){ | ||
| 48 | -// UIImage *info = [dic objectForKey:@"info"]; | ||
| 49 | -// _header.image = info; | ||
| 50 | -// | ||
| 51 | -// }else if(type == XWUserInfoDataTypeNickname){ | ||
| 52 | -// NSString *info = [dic objectForKey:@"info"]; | ||
| 53 | -// _name.attributedText = [self createAttributedImageName:@"mine_code" string:info isFront:NO]; | ||
| 54 | -// | ||
| 55 | -// }else if(type == XWUserInfoDataTypeAddress){ | ||
| 56 | -// NSString *info = [dic objectForKey:@"info"]; | ||
| 57 | -// _address.attributedText = [self createAttributedImageName:@"mine_location" string:info isFront:YES]; | ||
| 58 | -// | ||
| 59 | -// } | 46 | + NSDictionary *dic = [noti userInfo]; |
| 47 | + CNLiveUserInfoDataType type = [[dic objectForKey:@"type"] integerValue]; | ||
| 48 | + NSString *info = [dic objectForKey:@"info"]; | ||
| 49 | + if(type == CNLiveUserInfoDataTypeHead){ | ||
| 50 | + UIImage *xw_image = [self getImageWithImageName:@"default_avatar_y" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]]; | ||
| 51 | + [_header sd_setImageWithURL:[NSURL URLWithString:info] placeholderImage:xw_image]; | ||
| 52 | + | ||
| 53 | + }else if(type == CNLiveUserInfoDataTypeNickname){ | ||
| 54 | + _name.attributedText = [self createAttributedImageName:@"mine_code" string:info isFront:NO]; | ||
| 55 | + | ||
| 56 | + }else if(type == CNLiveUserInfoDataTypeAddress){ | ||
| 57 | + _address.attributedText = [self createAttributedImageName:@"mine_location" string:info isFront:YES]; | ||
| 58 | + | ||
| 59 | + } | ||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | - (void)dealloc { | 62 | - (void)dealloc { |
| 63 | NSLog(@"CNLiveMineHeaderView -- dealloc"); | 63 | NSLog(@"CNLiveMineHeaderView -- dealloc"); |
| 64 | -// [XWUserInfoNotification removeObserver:self]; | 64 | + [CNLiveUserInfoNotification removeObserver:self]; |
| 65 | 65 | ||
| 66 | } | 66 | } |
| 67 | 67 |