CloudVideoDayViewController.mm 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // CloudVideoDayViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2019/1/7.
  6. // Copyright © 2019年 XM. All rights reserved.
  7. //
  8. #import "CloudVideoDayViewController.h"
  9. #import "CloudVideoDownloadViewController.h"
  10. #import "ItemTableviewCell.h"
  11. #import "NSDate+TimeCategory.h"
  12. #import "Header.h"
  13. @interface CloudVideoDayViewController ()<UITableViewDelegate, UITableViewDataSource, CloudVideoConfigDelegate>
  14. {
  15. CloudVideoConfig *config;
  16. UITableView *tableV;
  17. NSMutableArray *videoArray;
  18. }
  19. @end
  20. @implementation CloudVideoDayViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. //初始化tableview数据
  24. [self initDataSource];
  25. [self configSubView];
  26. [self getVideoFileConfig];
  27. }
  28. - (void)viewWillDisappear:(BOOL)animated{
  29. //有加载状态、则取消加载
  30. if ([SVProgressHUD isVisible]){
  31. [SVProgressHUD dismiss];
  32. }
  33. }
  34. #pragma mark - 查询设备云存储视频信息
  35. - (void)getVideoFileConfig {
  36. [SVProgressHUD showWithStatus:TS("")];
  37. if (config == nil) {
  38. config = [[CloudVideoConfig alloc] init];
  39. config.delegate = self;
  40. }
  41. //查询今天的云图片,可以设置其他想要查询的日期
  42. [config searchCloudVideo:[NSDate dateFromString:self.dateStr format: DATEFORMATER ]];
  43. }
  44. #pragma mark 获取云图片代理回调
  45. - (void)getCloudVideoResult:(NSInteger)result {
  46. if (result >= 0) {
  47. [SVProgressHUD dismiss];
  48. videoArray = [config getCloudVideoFileArray];
  49. //成功,刷新界面数据
  50. [self.tableV reloadData];
  51. }else{
  52. [MessageUI ShowErrorInt:(int)result];
  53. }
  54. }
  55. #pragma mark - tableView代理方法
  56. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  57. return videoArray.count;
  58. }
  59. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  60. ItemTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemTableviewCell"];
  61. if (!cell) {
  62. cell = [[ItemTableviewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ItemTableviewCell"];
  63. }
  64. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  65. CLouldVideoResource *resource = [videoArray objectAtIndex:indexPath.row];
  66. //云图片时间和日期
  67. cell.textLabel.text = resource.beginDate;
  68. cell.Labeltext.text = resource.beginTime;
  69. cell.textLabel.numberOfLines = 0;
  70. cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
  71. return cell;
  72. }
  73. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  74. //点击下载云图片
  75. CloudVideoDownloadViewController *downloadVC = [[CloudVideoDownloadViewController alloc] init];
  76. [self.navigationController pushViewController:downloadVC animated:YES];
  77. CLouldVideoResource *recource = [videoArray objectAtIndex:indexPath.row];
  78. [downloadVC startDownloadCloudVideo:recource];
  79. }
  80. #pragma mark - 界面和数据初始化
  81. - (void)configSubView {
  82. self.title = TS("search_Video");
  83. [self.view addSubview:self.tableV];
  84. }
  85. - (UITableView *)tableV {
  86. if (!tableV) {
  87. tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight ) style:UITableViewStylePlain];
  88. tableV.delegate = self;
  89. tableV.dataSource = self;
  90. [tableV registerClass:[ItemTableviewCell class] forCellReuseIdentifier:@"ItemTableviewCell"];
  91. }
  92. return tableV;
  93. }
  94. #pragma mark - 界面和数据初始化
  95. - (void)initDataSource {
  96. videoArray = [[NSMutableArray alloc] initWithCapacity:0];
  97. }
  98. - (void)didReceiveMemoryWarning {
  99. [super didReceiveMemoryWarning];
  100. // Dispose of any resources that can be recreated.
  101. }
  102. @end