EaseCustomMessageCell.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /************************************************************
  2. * * Hyphenate CONFIDENTIAL
  3. * __________________
  4. * Copyright (C) 2016 Hyphenate Inc. All rights reserved.
  5. *
  6. * NOTICE: All information contained herein is, and remains
  7. * the property of Hyphenate Technologies.
  8. * Dissemination of this information or reproduction of this material
  9. * is strictly forbidden unless prior written permission is obtained
  10. * from Hyphenate Inc.
  11. */
  12. #import "EaseCustomMessageCell.h"
  13. #import "EaseBubbleView+Gif.h"
  14. #import "UIImageView+EMWebCache.h"
  15. #import "UIImage+EMGIF.h"
  16. #import "IMessageModel.h"
  17. @interface EaseCustomMessageCell ()
  18. @end
  19. @implementation EaseCustomMessageCell
  20. + (void)initialize
  21. {
  22. // UIAppearance Proxy Defaults
  23. }
  24. #pragma mark - IModelCell
  25. - (BOOL)isCustomBubbleView:(id<IMessageModel>)model
  26. {
  27. return YES;
  28. }
  29. - (void)setCustomModel:(id<IMessageModel>)model
  30. {
  31. UIImage *image = model.image;
  32. if (!image) {
  33. [self.bubbleView.imageView sd_setImageWithURL:[NSURL URLWithString:model.fileURLPath] placeholderImage:[UIImage imageNamed:model.failImageName]];
  34. } else {
  35. _bubbleView.imageView.image = image;
  36. }
  37. if (model.avatarURLPath) {
  38. [self.avatarView sd_setImageWithURL:[NSURL URLWithString:model.avatarURLPath] placeholderImage:model.avatarImage];
  39. } else {
  40. self.avatarView.image = model.avatarImage;
  41. }
  42. }
  43. - (void)setCustomBubbleView:(id<IMessageModel>)model
  44. {
  45. [_bubbleView setupGifBubbleView];
  46. _bubbleView.imageView.image = [UIImage imageNamed:@"imageDownloadFail"];
  47. }
  48. - (void)updateCustomBubbleViewMargin:(UIEdgeInsets)bubbleMargin model:(id<IMessageModel>)model
  49. {
  50. [_bubbleView updateGifMargin:bubbleMargin];
  51. }
  52. /*!
  53. @method
  54. @brief 获取cell的重用标识
  55. @discussion
  56. @param model 消息model
  57. @return 返回cell的重用标识
  58. */
  59. + (NSString *)cellIdentifierWithModel:(id<IMessageModel>)model
  60. {
  61. return model.isSender?@"EaseMessageCellSendGif":@"EaseMessageCellRecvGif";
  62. }
  63. /*!
  64. @method
  65. @brief 获取cell的高度
  66. @discussion
  67. @param model 消息model
  68. @return 返回cell的高度
  69. */
  70. + (CGFloat)cellHeightWithModel:(id<IMessageModel>)model
  71. {
  72. return 100;
  73. }
  74. @end