Nenhuma Descrição

FKProActivityThemeCell.m 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // FKProActivityThemeCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 2016/11/11.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProActivityThemeCell.h"
  9. #import "FKProDetailViewModel.h"
  10. #import <SDWebImage/SDWebImageDownloader.h>
  11. #import "FLImageHelper.h"
  12. #import "SchemaManager.h"
  13. @interface FKProActivityThemeCell ()
  14. @property (nonatomic, strong) UIImageView *themeImgView;
  15. @property (nonatomic, strong) NSString *targetUrl;
  16. @end
  17. @implementation FKProActivityThemeCell
  18. /*
  19. // Only override drawRect: if you perform custom drawing.
  20. // An empty implementation adversely affects performance during animation.
  21. - (void)drawRect:(CGRect)rect {
  22. // Drawing code
  23. }
  24. */
  25. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  26. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  27. if (self) {
  28. [self.contentView addSubview:self.themeImgView];
  29. [self.themeImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.edges.equalTo(self.contentView);
  31. }];
  32. }
  33. return self;
  34. }
  35. #pragma mark -
  36. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath {
  37. if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
  38. FKProDetailViewModel *detailModel = (FKProDetailViewModel*)viewModel;
  39. NSString *imageUrl = detailModel.dataItem.themeItem.photoURL;
  40. self.targetUrl = detailModel.dataItem.themeItem.targetURL;
  41. if (imageUrl.length > 0) {
  42. [self.themeImgView setImageWithURL:imageUrl placeholderImage:nil width:UISCREENWIDTH height:[FKProActivityBaseCell height]];
  43. }
  44. }
  45. }
  46. -(void)clickThemeImageView {
  47. if (self.targetUrl.length > 0) {
  48. [[SchemaManager sharedManager] parserURL:[NSURL URLWithString:self.targetUrl] shouldCache:NO];
  49. }
  50. }
  51. #pragma mark - Property
  52. - (UIImageView *)themeImgView {
  53. if (!_themeImgView) {
  54. _themeImgView = [UIImageView new];
  55. _themeImgView.userInteractionEnabled = YES;
  56. [_themeImgView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickThemeImageView)]];
  57. }
  58. return _themeImgView;
  59. }
  60. @end