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
//
//  Copyright © 2020 dahua. All rights reserved.
//
 
#import "LCLivePreviewPresenter+VideotapeList.h"
 
static const void *kVideotapeList = @"videotapeHistoryList";
 
@implementation LCLivePreviewPresenter (VideotapeList)
 
- (void)loadCloudVideotape {
    weakSelf(self);
//    if (![self.videoManager.currentChannelInfo.storageStrategyStatus isEqualToString:@"using"]) {
//        LCError * err = [LCError errorWithCode:@"" errorMessage:@"device_manager_no_cloud_storage".lc_T errorInfo:nil];
//        [self setErrorViewWith:err];
//        return;
//    }
    [self.historyView startAnimation];
    [LCVideotapeInterface getCloudRecordsForDevice:self.videoManager.currentDevice.deviceId channelId:self.videoManager.currentChannelInfo.channelId day:[NSDate new] From:-1 Count:6 success:^(NSMutableArray<LCCloudVideotapeInfo *> *_Nonnull videos) {
        if (videos.count == 0) {
            [self setErrorViewWith:nil];
        } else {
            [weakself willChangeValueForKey:@"videotapeList"];
            weakself.videotapeList = videos;
            [weakself didChangeValueForKey:@"videotapeList"];
        }
    } failure:^(LCError *_Nonnull error) {
        [self setErrorViewWith:error];
    }];
}
 
- (void)loadLocalVideotape {
    weakSelf(self);
    [self.historyView startAnimation];
    [LCVideotapeInterface queryLocalRecordsForDevice:self.videoManager.currentDevice.deviceId channelId:self.videoManager.currentChannelInfo.channelId day:[NSDate new] From:1 To:6 success:^(NSMutableArray<LCLocalVideotapeInfo *> *_Nonnull videos) {
        if (videos.count == 0) {
            [self setErrorViewWith:nil];
        } else {
            [weakself willChangeValueForKey:@"videotapeList"];
            weakself.videotapeList = videos;
            [weakself didChangeValueForKey:@"videotapeList"];
        }
    } failure:^(LCError *_Nonnull error) {
        [self setErrorViewWith:error];
    }];
}
 
- (void)setErrorViewWith:(LCError *)error {
    weakSelf(self);
    LCButton *errorBtn = [LCButton lcButtonWithType:LCButtonTypeShadow];
    if (!error) {
        //展示无数据
        [errorBtn setTitle:@"play_module_none_record".lc_T forState:UIControlStateNormal];
        errorBtn.touchUpInsideblock = ^(LCButton *_Nonnull btn) {
            [weakself.liveContainer.navigationController pushToVideotapeListPageWithType:(self.historyView.isCurrentCloud ? 0 : 1)];
        };
    } else {
        [errorBtn setTitle:error.errorMessage forState:UIControlStateNormal];
    }
    [self.historyView setupErrorView:errorBtn];
}
 
- (void)setHistoryView:(LCVideoHistoryView *)historyView {
    objc_setAssociatedObject(self, kVideotapeList, historyView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
 
- (LCVideoHistoryView *)historyView {
    return objc_getAssociatedObject(self, kVideotapeList);
}
 
@end