RQDspVideoDetailCell.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // RQDspVideoDetailCell.m
  3. // JSJP
  4. //
  5. // Created by RONGQING on 2022/1/20.
  6. //
  7. #import "RQDspVideoDetailCell.h"
  8. @interface RQDspVideoDetailCell ()
  9. @property (nonatomic, readwrite, strong) RQDspVideoDetailItemViewModel *viewModel;
  10. @property (weak, nonatomic) IBOutlet UIImageView *coverImageView;
  11. @end
  12. @implementation RQDspVideoDetailCell
  13. #pragma mark - PublicMethods
  14. + (instancetype)cellWithTableView:(UITableView *)tableView {
  15. static NSString *ID = @"RQDspVideoDetailCell";
  16. RQDspVideoDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  17. if (!cell) {
  18. cell = [self rq_viewFromXib];
  19. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  20. cell.coverImageView.userInteractionEnabled = YES;
  21. cell.coverImageView.tag = 10086;
  22. }
  23. return cell;
  24. }
  25. - (void)bindViewModel:(RQDspVideoDetailItemViewModel *)viewModel {
  26. _viewModel = viewModel;
  27. if (RQStringIsNotEmpty(viewModel.videosItem.coverFileUrl)) {
  28. if (RQObjectIsNil(viewModel.videosItem.adView)) {
  29. [_coverImageView yy_setImageWithURL:[NSURL URLWithString:viewModel.videosItem.coverFileUrl] placeholder:RQWebVideoImagePlaceholder() options:RQWebImageOptionAutomatic completion:nil];
  30. } else {
  31. self.adView = viewModel.videosItem.adView;
  32. }
  33. }
  34. }
  35. - (void)setAdView:(UIView *)adView {
  36. if(_adView == adView)
  37. return;
  38. if(_adView.superview == self)
  39. [_adView removeFromSuperview];
  40. _adView = adView;
  41. [self.contentView addSubview:adView];
  42. adView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT);
  43. }
  44. #pragma mark - SystemMethods
  45. - (void)awakeFromNib {
  46. [super awakeFromNib];
  47. // Initialization code
  48. }
  49. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  50. [super setSelected:selected animated:animated];
  51. // Configure the view for the selected state
  52. }
  53. - (void)layoutSubviews {
  54. _adView.frame = self.contentView.bounds;
  55. }
  56. @end