NIMMessageCellFactory.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // NIMMessageCellMaker.m
  3. // NIMKit
  4. //
  5. // Created by chris.
  6. // Copyright (c) 2015年 NetEase. All rights reserved.
  7. //
  8. #import "NIMMessageCellFactory.h"
  9. #import "NIMMessageModel.h"
  10. #import "NIMTimestampModel.h"
  11. #import "NIMSessionAudioContentView.h"
  12. #import "NIMKit.h"
  13. #import "NIMKitAudioCenter.h"
  14. #import "UIView+NIM.h"
  15. @interface NIMMessageCellFactory()
  16. @end
  17. @implementation NIMMessageCellFactory
  18. - (instancetype)init
  19. {
  20. self = [super init];
  21. if (self) {
  22. }
  23. return self;
  24. }
  25. - (void)dealloc
  26. {
  27. }
  28. - (NIMMessageCell *)cellInTable:(UITableView*)tableView
  29. forMessageMode:(NIMMessageModel *)model
  30. {
  31. id<NIMCellLayoutConfig> layoutConfig = [[NIMKit sharedKit] layoutConfig];
  32. NSString *identity = [layoutConfig cellContent:model];
  33. NIMMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
  34. if (!cell) {
  35. NSString *clz = @"NIMMessageCell";
  36. [tableView registerClass:NSClassFromString(clz) forCellReuseIdentifier:identity];
  37. cell = [tableView dequeueReusableCellWithIdentifier:identity];
  38. }
  39. return (NIMMessageCell *)cell;
  40. }
  41. - (NIMSessionTimestampCell *)cellInTable:(UITableView *)tableView
  42. forTimeModel:(NIMTimestampModel *)model
  43. {
  44. NSString *identity = @"time";
  45. NIMSessionTimestampCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
  46. if (!cell) {
  47. NSString *clz = @"NIMSessionTimestampCell";
  48. [tableView registerClass:NSClassFromString(clz) forCellReuseIdentifier:identity];
  49. cell = [tableView dequeueReusableCellWithIdentifier:identity];
  50. }
  51. [cell refreshData:model];
  52. return (NIMSessionTimestampCell *)cell;
  53. }
  54. @end