123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870 |
- //
- // 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
|