JXShakeCell.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // JXShakeCell.m
  3. // shiku_im
  4. //
  5. // Created by p on 2018/5/30.
  6. // Copyright © 2018年 Reese. All rights reserved.
  7. //
  8. #import "JXShakeCell.h"
  9. @implementation JXShakeCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. -(void)creatUI{
  15. self.shakeImageView = [[UIImageView alloc] init];
  16. [self.bubbleBg addSubview:self.shakeImageView];
  17. }
  18. - (void)setCellData {
  19. [super setCellData];
  20. NSMutableArray *array = [NSMutableArray array];
  21. NSString* file,*s;
  22. if(self.msg.isMySend)
  23. file = @"pj_right_";
  24. else
  25. file = @"pj_left_";
  26. for(int i=1;i<=6;i++){
  27. s = [NSString stringWithFormat:@"%@%d",file,i];
  28. [array addObject:[UIImage imageNamed:s]];
  29. }
  30. self.shakeImageView.animationImages = array;
  31. self.shakeImageView.animationDuration = 0.5;
  32. self.shakeImageView.animationRepeatCount = 2;
  33. self.shakeImageView.image = [array objectAtIndex:[array count]-1];
  34. if(self.msg.isMySend){
  35. self.bubbleBg.frame = CGRectMake(CGRectGetMinX(self.headImage.frame)-105-CHAT_WIDTH_ICON, 0, 105, 105);
  36. }
  37. else{
  38. self.bubbleBg.frame = CGRectMake(CGRectGetMaxX(self.headImage.frame) + CHAT_WIDTH_ICON, 5, 105, 105);
  39. }
  40. if ([self.msg.fileName intValue] == 0) {
  41. self.msg.fileName = @"1";
  42. [self.shakeImageView startAnimating];
  43. [self.msg updateFileName];
  44. }
  45. if (self.msg.isShowTime) {
  46. CGRect frame = self.bubbleBg.frame;
  47. frame.origin.y = self.bubbleBg.frame.origin.y + 40;
  48. self.bubbleBg.frame = frame;
  49. }
  50. self.shakeImageView.frame=self.bubbleBg.bounds;
  51. }
  52. -(void)didTouch:(UIButton*)button{
  53. [self.shakeImageView startAnimating];
  54. [g_notify postNotificationName:kCellSystemShakeNotifaction object:self.msg];
  55. }
  56. + (float)getChatCellHeight:(JXMessageObject *)msg {
  57. if ([msg.chatMsgHeight floatValue] > 1) {
  58. return [msg.chatMsgHeight floatValue];
  59. }
  60. float n = 0;
  61. if (msg.isGroup && !msg.isMySend) {
  62. if (msg.isShowTime) {
  63. n = 105+20*2 + 40;
  64. }else {
  65. n = 105+20*2;
  66. }
  67. n += GROUP_CHAT_INSET;
  68. }else {
  69. if (msg.isShowTime) {
  70. n = 105+10*2 + 40;
  71. }else {
  72. n = 105+10*2;
  73. }
  74. }
  75. msg.chatMsgHeight = [NSString stringWithFormat:@"%f",n];
  76. if (!msg.isNotUpdateHeight) {
  77. [msg updateChatMsgHeight];
  78. }
  79. return n;
  80. }
  81. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  82. [super setSelected:selected animated:animated];
  83. // Configure the view for the selected state
  84. }
  85. @end