DeviceListTableViewCell.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // DeviceListTableViewCell.m
  3. // FunSDKDemo
  4. //
  5. // Created by Levi on 2018/5/18.
  6. // Copyright © 2018年 Levi. All rights reserved.
  7. //
  8. #import "DeviceListTableViewCell.h"
  9. #import "Header.h"
  10. @implementation DeviceListTableViewCell
  11. - (UIImageView *)devImageV {
  12. if (!_devImageV) {
  13. _devImageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
  14. _devImageV.image = [UIImage imageNamed:@"xmjp_seye.png"];
  15. }
  16. return _devImageV;
  17. }
  18. - (UIImageView *)onlineState {
  19. if (!_onlineState) {
  20. _onlineState = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenWidth -85, 10, 75, 29)];
  21. }
  22. return _onlineState;
  23. }
  24. - (UILabel *)devName {
  25. if (!_devName) {
  26. _devName = [[UILabel alloc] initWithFrame:CGRectMake(60, 13, ScreenWidth - 60, 34)];
  27. _devName.font = [UIFont systemFontOfSize:18];
  28. _devName.text = TS("");
  29. }
  30. return _devName;
  31. }
  32. - (UILabel *)devType {
  33. if (!_devType) {
  34. _devType = [[UILabel alloc] initWithFrame:CGRectMake(60, 50, 100, 30)];
  35. _devType.text = TS("device_type");
  36. }
  37. return _devType;
  38. }
  39. - (UILabel *)devTypeLab {
  40. if (!_devTypeLab) {
  41. _devTypeLab = [[UILabel alloc] initWithFrame:CGRectMake(180, 50, ScreenWidth - 180, 30)];
  42. _devTypeLab.text = TS("雄迈摇头机");
  43. }
  44. return _devTypeLab;
  45. }
  46. - (UILabel *)devSN {
  47. if (!_devSN) {
  48. _devSN = [[UILabel alloc] initWithFrame:CGRectMake(60, 80, 120, 30)];
  49. _devSN.text = TS("serial_number");
  50. }
  51. return _devSN;
  52. }
  53. - (UILabel *)devSNLab {
  54. if (!_devSNLab) {
  55. _devSNLab = [[UILabel alloc] initWithFrame:CGRectMake(180, 80, ScreenWidth - 180, 30)];
  56. _devSNLab.text = TS("f893868a28d45392");
  57. }
  58. return _devSNLab;
  59. }
  60. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  61. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  62. if (self) {
  63. [self configSubView];
  64. }
  65. return self;
  66. }
  67. - (void)configSubView {
  68. [self.contentView addSubview:self.devImageV];
  69. [self.contentView addSubview:self.devName];
  70. [self.contentView addSubview:self.devType];
  71. [self.contentView addSubview:self.devTypeLab];
  72. [self.contentView addSubview:self.devSN];
  73. [self.contentView addSubview:self.devSNLab];
  74. [self.contentView addSubview:self.onlineState];
  75. }
  76. //设备在线状态
  77. - (void)setDeviceState:(int)state {
  78. if (state >0) {
  79. _onlineState.image = [UIImage imageNamed:@"online.png"];
  80. }else{
  81. _onlineState.image = [UIImage imageNamed:@"offline.png"];
  82. }
  83. }
  84. //EFunDevState 0 未知 1 唤醒 2 睡眠 3 不能被唤醒的休眠 4正在准备休眠
  85. - (void)setSleepType:(int)type {
  86. if (type == 4) {
  87. _onlineState.image = [UIImage imageNamed:@"Prepare_sleep.png"];
  88. }else if (type == 3){
  89. _onlineState.image = [UIImage imageNamed:@"sleepnotwakeup.png"];
  90. }else if (type == 2){
  91. _onlineState.image = [UIImage imageNamed:@"ic_sleep.png"];
  92. }
  93. }
  94. @end