HMHotTableViewCell.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. //
  2. // HMHotTableViewCell.m
  3. // BuguLive
  4. //
  5. // Created by xfg on 2017/7/5.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "HMHotTableViewCell.h"
  9. @implementation HMHotTableViewCell
  10. - (void)awakeFromNib
  11. {
  12. [super awakeFromNib];
  13. self.BuguLive = [GlobalVariables sharedInstance];
  14. self.headImgBtn.layer.borderWidth = 1;
  15. self.headImgBtn.layer.borderColor = [kAppGrayColor4 CGColor];
  16. self.headImgBtn.layer.cornerRadius = CGRectGetWidth(self.headImgBtn.frame) / 2;
  17. self.headImgBtn.clipsToBounds = YES;
  18. self.userNameLabel.textColor = kAppGrayColor1;
  19. self.areaLabel.backgroundColor = kAppMainColor;
  20. self.areaLabel.layer.masksToBounds = YES;
  21. self.areaLabel.edgeInsets = UIEdgeInsetsMake(0 , 8, 0, 8); // 设置内边距
  22. self.areaLabel.layer.cornerRadius = 8;
  23. self.watchNumLabel.textColor = kAppGrayColor3;
  24. self.liveStateLabel.layer.borderWidth = 1;
  25. self.liveStateLabel.clipsToBounds = YES;
  26. self.liveStateLabel.layer.cornerRadius = 10;
  27. self.liveStateLabel.layer.borderColor = kWhiteColor.CGColor;
  28. self.liveStateLabel.textColor = [UIColor whiteColor];
  29. self.liveStateLabel.backgroundColor = kGrayTransparentColor2_1;
  30. self.liveStateLabel.edgeInsets = UIEdgeInsetsMake(0 , 15, 0, 15); // 设置内边距
  31. [self.liveStateLabel sizeToFit]; // 重新计算尺寸
  32. self.livePriceLabel.layer.borderWidth = 1;
  33. self.livePriceLabel.clipsToBounds = YES;
  34. self.livePriceLabel.layer.cornerRadius = 10;
  35. self.livePriceLabel.layer.borderColor = kWhiteColor.CGColor;
  36. self.livePriceLabel.textColor = [UIColor whiteColor];
  37. self.liveStateLabel.backgroundColor = kGrayTransparentColor2_1;
  38. self.liveStateLabel.edgeInsets = UIEdgeInsetsMake(0 , 15, 0, 15); // 设置内边距
  39. [self.livePriceLabel sizeToFit]; // 重新计算尺寸
  40. self.gameStateLabel.layer.borderWidth = 1;
  41. self.gameStateLabel.clipsToBounds = YES;
  42. self.gameStateLabel.layer.cornerRadius = 10;
  43. self.gameStateLabel.layer.borderColor = kWhiteColor.CGColor;
  44. self.gameStateLabel.textColor = [UIColor whiteColor];
  45. self.gameStateLabel.backgroundColor = kGrayTransparentColor2_1;
  46. self.gameStateLabel.edgeInsets = UIEdgeInsetsMake(0 , 15, 0, 15); // 设置内边距
  47. [self.gameStateLabel sizeToFit]; // 重新计算尺寸
  48. self.lineLabel.backgroundColor = kBackGroundColor;
  49. self.liveDecLabel.textColor = RGB(167, 167, 167);
  50. }
  51. - (void)setSelected:(BOOL)selected animated:(BOOL)animated
  52. {
  53. [super setSelected:selected animated:animated];
  54. }
  55. - (void)initWidthModel:(HMHotItemModel *)hotItemModel rowIndex:(NSInteger)rowIndex
  56. {
  57. _rowIndex = rowIndex;
  58. [self.headImgBtn sd_setImageWithURL:[NSURL URLWithString:hotItemModel.head_image] forState:UIControlStateNormal placeholderImage:kDefaultPreloadHeadImg];
  59. FWWeakify(self)
  60. [self.headImgBtn setClickAction:^(id<MenuAbleItem> menu) {
  61. FWStrongify(self)
  62. if ([self.delegate respondsToSelector:@selector(clickUserIcon:)])
  63. {
  64. [self.delegate clickUserIcon:_rowIndex];
  65. }
  66. }];
  67. [self.autImgView sd_setImageWithURL:[NSURL URLWithString:hotItemModel.v_icon] placeholderImage:nil];
  68. self.userNameLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:hotItemModel.nick_name];
  69. self.areaLabel.text = hotItemModel.city;
  70. self.watchNumLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%@ 在看"),hotItemModel.watch_number];
  71. [self.liveImgView sd_setImageWithURL:[NSURL URLWithString:hotItemModel.live_image] placeholderImage:nil];
  72. if (![BGUtils isBlankString:hotItemModel.title])
  73. {
  74. self.liveDecLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:hotItemModel.title];
  75. }
  76. if (hotItemModel.is_live_pay)
  77. {
  78. if (hotItemModel.live_in == FW_LIVE_STATE_ING && [hotItemModel.is_live_pay isEqualToString:@"0"])
  79. {
  80. self.livePriceLabel.hidden = YES;
  81. self.gameStateSpaceTopLayout.constant = 26;
  82. }
  83. // else if (hotItemModel.live_in == FW_LIVE_STATE_RELIVE && [hotItemModel.is_live_pay isEqualToString:@"0"])
  84. // {
  85. // self.livePriceLabel.hidden = YES;
  86. // self.gameStateSpaceTopLayout.constant = 26;
  87. // }
  88. else if (hotItemModel.live_in == FW_LIVE_STATE_ING && [hotItemModel.is_live_pay isEqualToString:@"1"])
  89. {
  90. self.livePriceLabel.hidden = NO;
  91. self.gameStateSpaceTopLayout.constant = 52;
  92. if ([hotItemModel.live_pay_type isEqualToString:@"1"])
  93. {
  94. self.livePriceLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%@%@/场"),hotItemModel.live_fee,self.BuguLive.appModel.diamond_name];
  95. }
  96. else
  97. {
  98. self.livePriceLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%@%@/分钟"),hotItemModel.live_fee,self.BuguLive.appModel.diamond_name];
  99. }
  100. }
  101. // else if (hotItemModel.live_in == FW_LIVE_STATE_RELIVE && [hotItemModel.is_live_pay isEqualToString:@"1"])
  102. // {
  103. // self.livePriceLabel.hidden = NO;
  104. // self.gameStateSpaceTopLayout.constant = 52;
  105. // if ([hotItemModel.live_pay_type isEqualToString:@"1"])
  106. // {
  107. // self.livePriceLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%@%@/场"),hotItemModel.live_fee,self.BuguLive.appModel.diamond_name];
  108. // }
  109. // else
  110. // {
  111. // self.livePriceLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%@%@/分钟"),hotItemModel.live_fee,self.BuguLive.appModel.diamond_name];
  112. // }
  113. // }
  114. }
  115. else
  116. {
  117. self.livePriceLabel.hidden = YES;
  118. self.gameStateSpaceTopLayout.constant = 26;
  119. }
  120. if (![BGUtils isBlankString:hotItemModel.live_state])
  121. {
  122. self.liveStateLabelHeight.constant = 20;
  123. self.liveStateLabelSpaceTop.constant = 13;
  124. self.liveStateLabel.hidden = NO;
  125. self.liveStateLabel.text = hotItemModel.live_state;
  126. }else
  127. {
  128. self.liveStateLabelHeight.constant = 0;
  129. self.liveStateLabelSpaceTop.constant = 0;
  130. self.liveStateLabel.hidden = YES;
  131. }
  132. if ([hotItemModel.title isEqualToString:@""])
  133. {
  134. self.liveDecLabel.hidden = YES;
  135. self.noDecLayout.constant = 0;
  136. }
  137. else
  138. {
  139. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleToTopicVC:)];
  140. [self.liveDecLabel addGestureRecognizer:tap];
  141. self.liveDecLabel.hidden = NO;
  142. self.noDecLayout.constant = 42;
  143. }
  144. if ([hotItemModel.is_gaming isEqualToString:@"1"])
  145. {
  146. self.gameStateLabel.hidden = NO;
  147. if (![BGUtils isBlankString:hotItemModel.game_name])
  148. {
  149. self.gameStateLabel.text = hotItemModel.game_name;
  150. }
  151. }
  152. else
  153. {
  154. self.gameStateLabel.hidden = YES;
  155. }
  156. [self layoutIfNeeded];
  157. }
  158. #pragma mark -- 点击话题题目的点击事件
  159. - (void)handleToTopicVC:(UITapGestureRecognizer *)tap
  160. {
  161. if ([self.delegate respondsToSelector:@selector(pushToTopic:)])
  162. {
  163. [self.delegate pushToTopic:_rowIndex];
  164. }
  165. }
  166. @end