JLChen
2021-11-04 1443556e9ccb1a19ed8e6710c16c8adc4d4f4fb3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
//  Copyright © 2019 dahua. All rights reserved.
//
 
#import "LCDeviceListChannelCell.h"
#import "LCUIKit.h"
#import <SDWebImage/SDWebImage.h>
#import "UIImageView+Surface.h"
 
@interface LCDeviceListChannelCell ()
 
/// imageView
@property (strong, nonatomic) UIImageView *imageView;
 
/// imageView
@property (strong, nonatomic) UIImageView *playImg;
/// 离线遮罩View
@property (strong, nonatomic) UIView *maskView;
 
/// 离线Lab
@property (strong, nonatomic) UILabel *offlineLab;
/// 名称Lab
@property (strong, nonatomic) UILabel *nameLable;
 
 
@end
 
@implementation LCDeviceListChannelCell
 
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupView];
    }
    return self;
}
 
-(void)setupView{
    self.imageView = [UIImageView new];
    [self.contentView addSubview:self.imageView];
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.mas_equalTo(self);
    }];
    
    self.maskView = [UIView new];
    [self.contentView addSubview:self.maskView];
    [self.maskView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.mas_equalTo(self);
    }];
    self.maskView.backgroundColor = [UIColor dhcolor_c51];
    
    self.offlineLab = [UILabel new];
    [self.maskView addSubview:self.offlineLab];
    self.offlineLab.numberOfLines = 0;
    self.offlineLab.textColor = [UIColor dhcolor_c44];
    self.offlineLab.lineBreakMode = NSLineBreakByWordWrapping;
    [self.offlineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    UIImageView * playImg =[[UIImageView alloc] initWithImage:LC_IMAGENAMED(@"home_icon_play_big")];
    [self.contentView addSubview:playImg];
    self.playImg = playImg;
    [playImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
 
    
    self.nameLable = [UILabel new];
    [self addSubview:self.nameLable];
    self.nameLable.backgroundColor = [UIColor dhcolor_c51];
    self.nameLable.textColor = [UIColor dhcolor_c43];
    self.nameLable.adjustsFontSizeToFitWidth = YES;
    self.nameLable.minimumScaleFactor = 0.1;
    [self.nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.mas_equalTo(self);
    }];
    
    [self layoutIfNeeded];
    self.layer.cornerRadius = 3;
    self.layer.masksToBounds = YES;
}
 
-(void)setDeviceInfo:(LCDeviceInfo *)deviceInfo{
    _deviceInfo = deviceInfo;
    self.channelInfo = _deviceInfo.channels[self.index];
}
 
-(void)setChannelInfo:(LCChannelInfo *)channelInfo{
    _channelInfo = channelInfo;
     [self.imageView lc_setThumbImageWithURL:channelInfo.picUrl placeholderImage:LC_IMAGENAMED(@"common_defaultcover_big") DeviceId:channelInfo.deviceId ChannelId:channelInfo.channelId];
    self.nameLable.text = channelInfo.channelName;
    //仅在多通道设备上加名称显示
    self.nameLable.hidden = ([self.deviceInfo.catalog isEqualToString:@"NVR"])?NO:YES;
    if ([@"offline" isEqualToString:self.channelInfo.status] || [@"offline" isEqualToString:self.deviceInfo.status]) {
        //设备不在线或通道不在线
        self.playImg.hidden = YES;
        self.maskView.hidden = NO;
        self.offlineLab.hidden = NO;
        self.offlineLab.text = @"mobile_common_bec_device_offline".lc_T;
        
    }else{
        //设备在线
        self.playImg.hidden = NO;
        self.maskView.hidden = YES;
        self.offlineLab.hidden = YES;
    }
    
    self.userInteractionEnabled = [channelInfo.status isEqualToString:@"online"];
    
}
 
 
@end