CloudVideoViewController.mm 3.5 KB

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