ByTimeViewController.mm 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // ByTimeViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/14.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "ByTimeViewController.h"
  9. #import "VideoFileConfig.h"
  10. #import "ItemViewController.h"
  11. #import "ItemTableviewCell.h"
  12. @interface ByTimeViewController () <UITableViewDelegate, UITableViewDataSource, VideoFileConfigDelegate>
  13. {
  14. VideoFileConfig *config;
  15. UITableView *tableV;
  16. NSMutableArray *titleArray;
  17. }
  18. @end
  19. @implementation ByTimeViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. //初始化tableview数据
  23. [self initDataSource];
  24. [self configSubView];
  25. [self getVideoFileConfig];
  26. }
  27. - (void)viewWillDisappear:(BOOL)animated{
  28. //有加载状态、则取消加载
  29. if ([SVProgressHUD isVisible]){
  30. [SVProgressHUD dismiss];
  31. }
  32. }
  33. #pragma mark - 按时间查询设备录像信息
  34. - (void)getVideoFileConfig {
  35. [SVProgressHUD showWithStatus:TS("")];
  36. if (config == nil) {
  37. config = [[VideoFileConfig alloc] init];
  38. config.delegate = self;
  39. }
  40. //调用按时间查询录像的接口,查询今天的设备录像,可以自己设置日期,返回的是有录像的时间段对象数组
  41. [config getDeviceVideoByTime:[NSDate date]];
  42. }
  43. #pragma mark 获取摄像机参数代理回调
  44. - (void)getVideoResult:(NSInteger)result {
  45. if (result >= 0) {
  46. [SVProgressHUD dismiss];
  47. titleArray =[config getVideoTimeArray];
  48. //成功,刷新界面数据
  49. [self.tableV reloadData];
  50. }else{
  51. [MessageUI ShowErrorInt:(int)result];
  52. }
  53. }
  54. #pragma mark - tableView代理方法
  55. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  56. return titleArray.count;
  57. }
  58. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  59. ItemTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemTableviewCell"];
  60. if (!cell) {
  61. cell = [[ItemTableviewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ItemTableviewCell"];
  62. }
  63. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  64. TimeInfo *info = [titleArray objectAtIndex:indexPath.row];
  65. cell.textLabel.text = [NSString stringWithFormat:@"%d-%d",info.start_Time,info.end_Time];
  66. cell.textLabel.numberOfLines = 0;
  67. cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
  68. return cell;
  69. }
  70. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  71. }
  72. #pragma mark - 界面和数据初始化
  73. - (void)configSubView {
  74. [self.view addSubview:self.tableV];
  75. }
  76. - (UITableView *)tableV {
  77. if (!tableV) {
  78. tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight ) style:UITableViewStylePlain];
  79. tableV.delegate = self;
  80. tableV.dataSource = self;
  81. [tableV registerClass:[ItemTableviewCell class] forCellReuseIdentifier:@"ItemTableviewCell"];
  82. }
  83. return tableV;
  84. }
  85. #pragma mark - 界面和数据初始化
  86. - (void)initDataSource {
  87. titleArray = [[NSMutableArray alloc] initWithCapacity:0];
  88. }
  89. - (void)didReceiveMemoryWarning {
  90. [super didReceiveMemoryWarning];
  91. // Dispose of any resources that can be recreated.
  92. }
  93. @end