// // CommonListCell.m // smartRhino // // Created by niuzhen on 2020/4/28. // Copyright © 2020 tederen. All rights reserved. // #import "CommonListCell.h" @implementation CommonListCell - (void)awakeFromNib { [super awakeFromNib]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.iconShowL.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(3, 3)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = self.iconShowL.bounds; maskLayer.path = maskPath.CGPath; self.iconShowL.layer.mask = maskLayer; } + (CGFloat)configCell0Height{ return 72; } + (CommonListCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{ static NSString *cellIdentifer = @"CommonListCell0"; CommonListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer]; if (cell == nil) { cell = [[[NSBundle mainBundle] loadNibNamed:@"CommonListCell" owner:nil options:nil] objectAtIndex:0]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } + (CommonListCell *)configCell1:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{ static NSString *cellIdentifer = @"CommonListCell1"; CommonListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer]; if (cell == nil) { cell = [[[NSBundle mainBundle] loadNibNamed:@"CommonListCell" owner:nil options:nil] objectAtIndex:1]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } + (CommonListCell *)configCell2:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{ static NSString *cellIdentifer = @"CommonListCell2"; CommonListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer]; if (cell == nil) { cell = [[[NSBundle mainBundle] loadNibNamed:@"CommonListCell" owner:nil options:nil] objectAtIndex:2]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } - (void)setCell1Data:(MyFavoriteSubModel *)model { WS(weakSelf); self.nameL.hidden = NO; self.iconShowL.hidden = YES; self.comeBtn.hidden = YES; self.isTopV.hidden = !model.IsTop; [self.iconV removeAllSubviews]; [self.titleL mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.iconV.mas_right).offset(15); make.top.mas_offset(model.CollectionType == CollectModel_TopicBooK ? 40.25 : 15); make.height.mas_greaterThanOrEqualTo(20); make.width.mas_lessThanOrEqualTo(SCREEN_WIDTH - (model.IsTop ? 125 : 85)); }]; self.titleL.text = [model.Data.Title length] > 0 ? model.Data.Title : model.Title; self.nameL.text = [model.Data.Author length] > 0 ? model.Data.Author : @" "; [self.desBtn setTitle:[model.FolderName length] > 0 ? model.FolderName : @" " forState:UIControlStateNormal]; switch (model.CollectionType) { // 文章 case CollectModel_Aritle:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; } }]; }break; case CollectModel_MediaAritle:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; } }]; }break; // 话题 || 小组 case CollectModel_Toipc: { self.iconV.image = IMG(@"话题"); self.comeBtn.hidden = NO; [self.comeBtn setAttributedTitle:[self comeGroup:model.Data.GroupName] forState:UIControlStateNormal]; }break; case CollectModel_NewTopic: { self.iconV.image = IMG(@"话题"); }break; case CollectModel_Group:{ self.iconV.image = IMG(@"笔记小组"); }break; // 收藏 case CollectModel_Collect:{ self.iconV.image = IMG(@"收藏"); }break; // 笔记 case CollectModel_NoteBook: { self.iconV.image = IMG(@"noteBook_icon"); }break; case CollectModel_CollectFile:{ self.titleL.text = model.Title; self.iconV.image = IMG(@"find_1"); self.comeBtn.hidden = NO; self.nameL.text = @""; self.comeLeft.constant = 0.f; [self.comeBtn setAttributedTitle:[self comeGroup:[NSString stringWithFormat:@"%@的收藏",model.Data.Author]] forState:UIControlStateNormal]; }break; case CollectModel_NoteFile: { self.iconV.image = IMG(@"find_1"); }break; case CollectModel_TopicSubBooK: { self.iconV.image = IMG(@"find_1"); }break; // 通知 || 站内信 case CollectModel_Notice: { self.iconV.image = IMG(@"通知图标"); }break; case CollectModel_InterMail:{ self.iconV.image = IMG(@"站内信"); }break; // 会议 case CollectModel_meetMian: { self.iconV.image = IMG(@"会议纪要"); } break; case CollectModel_meetDetail: { self.iconV.image = IMG(@"会议"); } break; case CollectModel_file:{ NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName]; if (imageStr.length == 0) { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.File]]; }else{ self.iconV.image = IMG(imageStr); } }break; case CollectModel_work: { self.iconV.image = IMG(@"审批"); } break; case CollectModel_StoreSound: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_audio") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { dispatch_async(dispatch_get_main_queue(), ^{ UIImageView * clearV = [UIImageView new]; [weakSelf.iconV addSubview:clearV]; clearV.image = IMG(@"clear_audio"); [clearV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(weakSelf.iconV); }]; }); }]; } break; case CollectModel_StoreVideo: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_video") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { dispatch_async(dispatch_get_main_queue(), ^{ UIImageView * clearV = [UIImageView new]; [weakSelf.iconV addSubview:clearV]; clearV.image = IMG(@"clear_video"); [clearV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(weakSelf.iconV); }]; }); }]; } break; case CollectModel_Organization: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")]; } break; case CollectModel_financeCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_affairsCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_publishCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_StoreBook:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"图 书"; } }]; self.nameL.text = [NSString stringWithFormat:@"%@ %@",model.Data.Author,ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreMing:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"名 栏"; } }]; self.nameL.text = [NSString stringWithFormat:@"名栏: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreQiKan:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"期 刊"; } }]; self.nameL.text = [NSString stringWithFormat:@"主办单位: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreGongzh:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"公众号"; } }]; self.nameL.text = [NSString stringWithFormat:@"公众号: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; default:{ NSString * imageStr = [ZYCTool getFileNameImage:model.Title]; if (imageStr.length == 0) { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]]; }else{ self.iconV.image = IMG(imageStr); } }break; } } - (void)image:(UIImage *)image clearImage:(NSString *)clearImage IconV:(UIImageView *)imgV { UIImage *image1 = [UIImage imageNamed:clearImage]; CGSize size = CGSizeMake([UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height); UIGraphicsBeginImageContext(size); [image drawInRect:CGRectMake(0, 0, 40,40)]; [image1 drawInRect:CGRectMake(0, 0, 40,40)]; UIImage *ZImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); imgV.image = ZImage; } - (void)setCalayerImage:(UIImageView *)imgV image:(NSString *)image { CALayer *mask = [CALayer layer]; mask.contents = (id)[[UIImage imageNamed:image] CGImage]; mask.frame = CGRectMake(0, 0, 40, 40); imgV.layer.mask = mask; imgV.layer.masksToBounds = YES; } - (void)setCellTopicBookData:(MyFavoriteSubModel *)model { self.iconV.image = IMG(@"topicBook"); self.isTopV.hidden = !model.IsTop; self.titleL.text = model.Data.Title; [self.desBtn setTitle:[model.FolderName length] > 0 ? model.FolderName : @" " forState:UIControlStateNormal]; } - (void)setCellNoAuthorData:(MyFavoriteSubModel *)model { WS(weakSelf); self.nameL.hidden = NO; self.iconShowL.hidden = YES; self.comeBtn.hidden = YES; self.isTopV.hidden = !model.IsTop; self.titleL.text = [model.Data.Title length] > 0 ? model.Data.Title : model.Title; [self.desBtn setTitle:[model.FolderName length] > 0 ? model.FolderName : @"" forState:UIControlStateNormal]; [self.iconV removeAllSubviews]; switch (model.CollectionType) { // 文章 case CollectModel_Aritle:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"文 章"; } }]; }break; case CollectModel_Toipc: // 话题 || 小组 { self.iconV.image = IMG(@"话题"); self.comeBtn.hidden = NO; [self.comeBtn setAttributedTitle:[self comeGroup:model.Data.GroupName] forState:UIControlStateNormal]; }break; case CollectModel_NewTopic: { self.iconV.image = IMG(@"话题"); }break; case CollectModel_Group:{ self.iconV.image = IMG(@"笔记小组"); }break; // 收藏 case CollectModel_Collect:{ self.iconV.image = IMG(@"收藏"); }break; // 笔记 case CollectModel_NoteBook: { self.iconV.image = IMG(@"noteBook_icon"); }break; case CollectModel_CollectFile:{ self.titleL.text = model.Title; self.iconV.image = IMG(@"find_1"); self.comeBtn.hidden = NO; self.nameL.text = @""; self.comeLeft.constant = 0.f; [self.comeBtn setAttributedTitle:[self comeGroup:[NSString stringWithFormat:@"%@的收藏",model.Data.Author]] forState:UIControlStateNormal]; }break; case CollectModel_NoteFile: { self.iconV.image = IMG(@"find_1"); }break; case CollectModel_TopicSubBooK: { self.iconV.image = IMG(@"find_1"); }break; // 通知 || 站内信 case CollectModel_Notice: { self.iconV.image = IMG(@"通知图标"); }break; case CollectModel_InterMail:{ self.iconV.image = IMG(@"站内信"); }break; // 会议 case CollectModel_meetMian: { self.iconV.image = IMG(@"会议纪要"); } break; case CollectModel_meetDetail: { self.iconV.image = IMG(@"会议"); } break; case CollectModel_file:{ NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName]; if (imageStr.length == 0) { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.File]]; }else{ self.iconV.image = IMG(imageStr); } } break; case CollectModel_work: { self.iconV.image = IMG(@"审批"); } break; case CollectModel_financeCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_StoreBook:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"图 书"; } }]; self.nameL.text = [NSString stringWithFormat:@"%@ %@",model.Data.Author,ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreMing:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"名 栏"; } }]; self.nameL.text = [NSString stringWithFormat:@"名栏: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreQiKan:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"期 刊"; } }]; self.nameL.text = [NSString stringWithFormat:@"主办单位: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreGongzh:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"公众号"; } }]; self.nameL.text = [NSString stringWithFormat:@"公众号: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreSound: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_audio") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { dispatch_async(dispatch_get_main_queue(), ^{ UIImageView * clearV = [UIImageView new]; [weakSelf.iconV addSubview:clearV]; clearV.image = IMG(@"clear_audio"); [clearV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(weakSelf.iconV); }]; }); }]; } break; case CollectModel_StoreVideo: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_video") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { dispatch_async(dispatch_get_main_queue(), ^{ UIImageView * clearV = [UIImageView new]; [weakSelf.iconV addSubview:clearV]; clearV.image = IMG(@"clear_video"); [clearV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(weakSelf.iconV); }]; }); }]; } break; case CollectModel_Teacher: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")]; self.titleL.text = model.Data.Author; self.nameL.hidden = YES; } break; case CollectModel_Organization: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")]; self.titleL.text = model.Data.Author; self.nameL.hidden = YES; } break; case CollectModel_affairsCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_publishCount: { self.iconV.image = IMG(@"报表"); } break; default:{ NSString * imageStr = [ZYCTool getFileNameImage:model.Title]; if (imageStr.length == 0) { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]]; }else{ self.iconV.image = IMG(imageStr); } }break; } } - (void)setCellNoAuthorData:(MyFavoriteSubModel *)model withText:(NSString *)text { WS(weakSelf); self.nameL.hidden = NO; self.iconShowL.hidden = YES; self.comeBtn.hidden = YES; self.isTopV.hidden = !model.IsTop; self.titleL.attributedText = [ZYCTool checkOfString:model.Data.Title withSearchText:text withColor:UIColorHex(0xFF5252)]; self.nameL.attributedText = [model.Data.Author length] > 0 ? [ZYCTool checkOfString:model.Data.Author withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "]; [self.desBtn setAttributedTitle:[model.FolderName length] > 0 ? [ZYCTool checkOfString:model.FolderName withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "] forState:UIControlStateNormal]; [self.iconV removeAllSubviews]; switch (model.CollectionType) { // 文章 case CollectModel_Aritle:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章")]; }break; // 话题 || 小组 case CollectModel_Toipc: { self.iconV.image = IMG(@"话题"); self.comeBtn.hidden = NO; [self.comeBtn setAttributedTitle:[self comeGroup:model.GroupName] forState:UIControlStateNormal]; }break; case CollectModel_NewTopic: { self.iconV.image = IMG(@"话题"); }break; case CollectModel_Group:{ self.iconV.image = IMG(@"笔记小组"); }break; // 收藏 case CollectModel_Collect:{ self.iconV.image = IMG(@"收藏"); }break; // 笔记 case CollectModel_NoteBook: { self.iconV.image = IMG(@"noteBook_icon"); }break; case CollectModel_CollectFile:{ self.titleL.attributedText = [ZYCTool checkOfString:model.Title withSearchText:text withColor:UIColorHex(0xFF5252)]; self.iconV.image = IMG(@"find_1"); self.comeBtn.hidden = NO; self.nameL.text = @""; self.comeLeft.constant = 0.f; [self.comeBtn setAttributedTitle:[self comeGroup:[NSString stringWithFormat:@"%@的收藏",model.Data.Author]] forState:UIControlStateNormal]; }break; case CollectModel_NoteFile: { self.iconV.image = IMG(@"find_1"); }break; case CollectModel_TopicBooK:{ self.iconV.image = IMG(@"topicBook"); }break; case CollectModel_TopicSubBooK: { self.iconV.image = IMG(@"find_1"); }break; // 通知 || 站内信 case CollectModel_Notice: { self.iconV.image = IMG(@"通知图标"); }break; case CollectModel_InterMail:{ self.iconV.image = IMG(@"站内信"); }break; // 会议 case CollectModel_meetMian: { self.iconV.image = IMG(@"会议纪要"); } break; case CollectModel_meetDetail: { self.iconV.image = IMG(@"会议"); } break; case CollectModel_file:{ NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName]; if (imageStr.length == 0) { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.File]]; }else{ self.iconV.image = IMG(imageStr); } }break; case CollectModel_work: { self.iconV.image = IMG(@"审批"); } break; case CollectModel_StoreSound: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_audio") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { dispatch_async(dispatch_get_main_queue(), ^{ UIImageView * clearV = [UIImageView new]; [weakSelf.iconV addSubview:clearV]; clearV.image = IMG(@"clear_audio"); [clearV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(weakSelf.iconV); }]; }); }]; } break; case CollectModel_StoreVideo: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_video") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { dispatch_async(dispatch_get_main_queue(), ^{ UIImageView * clearV = [UIImageView new]; [weakSelf.iconV addSubview:clearV]; clearV.image = IMG(@"clear_video"); [clearV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(weakSelf.iconV); }]; }); }]; } break; case CollectModel_Teacher: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")]; self.titleL.attributedText = [model.Data.Author length] > 0 ? [ZYCTool checkOfString:model.Data.Author withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "]; self.nameL.hidden = YES; } break; case CollectModel_Organization: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")]; } break; case CollectModel_financeCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_affairsCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_publishCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_StoreBook:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"图 书"; } }]; self.nameL.text = [NSString stringWithFormat:@"%@ %@",model.Data.Author,ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreMing:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"名 栏"; } }]; self.nameL.text = [NSString stringWithFormat:@"名栏: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreQiKan:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"期 刊"; } }]; self.nameL.text = [NSString stringWithFormat:@"主办单位: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreGongzh:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"公众号"; } }]; self.nameL.text = [NSString stringWithFormat:@"公众号: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; default:{ NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName]; if (imageStr.length == 0) { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]]; }else{ self.iconV.image = IMG(imageStr); } }break; } } - (void)setCellData:(MyFavoriteSubModel *)model withText:(NSString *)text { WS(weakSelf); self.nameL.hidden = NO; self.iconShowL.hidden = YES; self.comeBtn.hidden = YES; self.isTopV.hidden = !model.IsTop; self.isTopV.hidden = !model.IsTop; self.titleL.attributedText = [ZYCTool checkOfString:model.Data.Title withSearchText:text withColor:UIColorHex(0xFF5252)]; self.nameL.attributedText = [model.Data.Author length] > 0 ? [ZYCTool checkOfString:model.Data.Author withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "]; [self.desBtn setAttributedTitle:[model.FolderName length] > 0 ? [ZYCTool checkOfString:model.FolderName withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "] forState:UIControlStateNormal]; self.comeBtn.hidden = YES; switch (model.CollectionType) { // 文章 case CollectModel_Aritle:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章")]; }break; // 话题 || 小组 case CollectModel_Toipc: { self.iconV.image = IMG(@"话题"); self.comeBtn.hidden = NO; [self.comeBtn setAttributedTitle:[self comeGroup:model.GroupName] forState:UIControlStateNormal]; }break; case CollectModel_NewTopic: { self.iconV.image = IMG(@"话题"); }break; case CollectModel_Group:{ self.iconV.image = IMG(@"笔记小组"); }break; // 收藏 case CollectModel_Collect:{ self.iconV.image = IMG(@"收藏"); }break; // 笔记 case CollectModel_NoteBook: { self.iconV.image = IMG(@"noteBook_icon"); }break; case CollectModel_CollectFile:{ self.titleL.attributedText = [ZYCTool checkOfString:model.Title withSearchText:text withColor:UIColorHex(0xFF5252)]; self.iconV.image = IMG(@"find_1"); self.comeBtn.hidden = NO; self.nameL.text = @""; self.comeLeft.constant = 0.f; [self.comeBtn setAttributedTitle:[self comeGroup:[NSString stringWithFormat:@"%@的收藏",model.Data.Author]] forState:UIControlStateNormal]; }break; case CollectModel_NoteFile: { self.iconV.image = IMG(@"find_1"); }break; case CollectModel_TopicBooK:{ self.iconV.image = IMG(@"topicBook"); }break; case CollectModel_TopicSubBooK: { self.iconV.image = IMG(@"find_1"); }break; // 通知 || 站内信 case CollectModel_Notice: { self.iconV.image = IMG(@"通知图标"); }break; case CollectModel_InterMail:{ self.iconV.image = IMG(@"站内信"); }break; // 会议 case CollectModel_meetMian: { self.iconV.image = IMG(@"会议纪要"); } break; case CollectModel_meetDetail: { self.iconV.image = IMG(@"会议"); } break; case CollectModel_file:{ NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName]; if (imageStr.length == 0) { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.File]]; }else{ self.iconV.image = IMG(imageStr); } }break; case CollectModel_work: { self.iconV.image = IMG(@"审批"); } break; case CollectModel_StoreSound: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_audio") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { dispatch_async(dispatch_get_main_queue(), ^{ UIImageView * clearV = [UIImageView new]; [weakSelf.iconV addSubview:clearV]; clearV.image = IMG(@"clear_audio"); [clearV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(weakSelf.iconV); }]; }); }]; } break; case CollectModel_StoreVideo: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_video") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { dispatch_async(dispatch_get_main_queue(), ^{ UIImageView * clearV = [UIImageView new]; [weakSelf.iconV addSubview:clearV]; clearV.image = IMG(@"clear_video"); [clearV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(weakSelf.iconV); }]; }); }]; } break; case CollectModel_Teacher: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")]; self.titleL.attributedText = [model.Data.Author length] > 0 ? [ZYCTool checkOfString:model.Data.Author withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "]; self.nameL.hidden = YES; } break; case CollectModel_Organization: { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")]; } break; case CollectModel_financeCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_affairsCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_publishCount: { self.iconV.image = IMG(@"报表"); } break; case CollectModel_StoreBook:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"图 书"; } }]; self.nameL.text = [NSString stringWithFormat:@"%@ %@",model.Data.Author,ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreMing:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"名 栏"; } }]; self.nameL.text = [NSString stringWithFormat:@"名栏: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreQiKan:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"期 刊"; } }]; self.nameL.text = [NSString stringWithFormat:@"主办单位: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; case CollectModel_StoreGongzh:{ [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { if (image) { weakSelf.iconShowL.hidden = NO; weakSelf.iconShowL.text = @"公众号"; } }]; self.nameL.text = [NSString stringWithFormat:@"公众号: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press]; }break; default:{ NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName]; if (imageStr.length == 0) { [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]]; }else{ self.iconV.image = IMG(imageStr); } }break; } } - (NSAttributedString *)comeGroup:(NSString *)name { NSString * comStr = [NSString stringWithFormat:@"来自-%@",name]; return [self checkOfString:comStr withSearchText:name]; } - (NSMutableAttributedString *)checkOfString:(NSString *)infoStr withSearchText:(NSString *)text { if (infoStr.length == 0 || text.length == 0) { return nil; } NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:infoStr]; [attrString addAttribute:(NSString *)NSForegroundColorAttributeName value:UIColorHex(0x999999) range:[infoStr rangeOfString:infoStr]]; [attrString addAttribute:(NSString *)NSForegroundColorAttributeName value:UIColorHex(0x1F87DB) range:[infoStr rangeOfString:text]]; return attrString; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end