StorageViewController.mm 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. //
  2. // StorageViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/18.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "StorageViewController.h"
  9. #import "ItemViewController.h"
  10. #import "ItemTableviewCell.h"
  11. #import "StorageConfig.h"
  12. @interface StorageViewController () <UITableViewDelegate,UITableViewDataSource,StorageConfigDelegate>
  13. {
  14. StorageConfig *config; //摄像机参数配置 (图像翻转等等)
  15. UITableView *tableV;
  16. NSMutableArray *titleArray;
  17. }
  18. @end
  19. @implementation StorageViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. //初始化tableview数据
  23. [self initDataSource];
  24. [self configSubView];
  25. // 获取设备存储配置
  26. [self getDeviceStorageConfig];
  27. }
  28. - (void)viewWillDisappear:(BOOL)animated{
  29. //有加载状态、则取消加载
  30. if ([SVProgressHUD isVisible]){
  31. [SVProgressHUD dismiss];
  32. }
  33. }
  34. #pragma mark - 获取设备存储配置
  35. - (void)getDeviceStorageConfig {
  36. [SVProgressHUD showWithStatus:TS("")];
  37. if (config == nil) {
  38. config = [[StorageConfig alloc] init];
  39. config.delegate = self;
  40. }
  41. //调用获取设备存储配置的接口
  42. [config getStorageInfoConfig];
  43. }
  44. #pragma mark 设备存储信息结果回调
  45. - (void)requestDeviceStorageResult:(NSInteger)result; {
  46. if (result >0) {
  47. //成功,刷新界面数据
  48. [self.tableV reloadData];
  49. [SVProgressHUD dismiss];
  50. }else{
  51. [MessageUI ShowErrorInt:(int)result];
  52. }
  53. }
  54. #pragma mark 保存设备普通录像的循环录像代理回调
  55. - (void)setOverWrightConfigResult:(NSInteger)result {
  56. if (result >0) {
  57. //成功
  58. [SVProgressHUD dismissWithSuccess:TS("Success")];
  59. }else{
  60. [MessageUI ShowErrorInt:(int)result];
  61. }
  62. }
  63. #pragma mark 保存设备原始录像的循环录像代理回调
  64. - (void)setKeyOverWrightConfigResult:(NSInteger)result {
  65. if (result >0) {
  66. //成功
  67. [SVProgressHUD dismissWithSuccess:TS("Success")];
  68. }else{
  69. [MessageUI ShowErrorInt:(int)result];
  70. }
  71. }
  72. #pragma mark 格式化设备存储空间代理回调
  73. - (void)clearStorageResult:(NSInteger)result {
  74. if (result >0) {
  75. //成功
  76. [SVProgressHUD dismissWithSuccess:TS("Success")];
  77. }else{
  78. [MessageUI ShowErrorInt:(int)result];
  79. }
  80. }
  81. #pragma mark - tableView代理方法
  82. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  83. return titleArray.count;
  84. }
  85. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  86. ItemTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemTableviewCell"];
  87. if (!cell) {
  88. cell = [[ItemTableviewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ItemTableviewCell"];
  89. }
  90. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  91. NSString *title = [titleArray objectAtIndex:indexPath.row];
  92. cell.textLabel.text = title;
  93. if (config.storage.totalStorage <=0.01) { //数据异常,直接return
  94. return cell;
  95. }
  96. if ([title isEqualToString:TS("Total_Capacity")]) {
  97. cell.Labeltext.text = [NSString stringWithFormat:@"%.01fK",config.storage.totalStorage];
  98. }else if ([title isEqualToString:TS("Residual_Capacity")]) {
  99. cell.Labeltext.text = [NSString stringWithFormat:@"%.01fK",config.storage.freeStorage];
  100. }else if ([title isEqualToString:TS("video_Capacity")]) {
  101. cell.Labeltext.text = [NSString stringWithFormat:@"%.01fK",config.storage.videoTotalStorage];
  102. }else if ([title isEqualToString:TS("video_re_capacity")]) {
  103. cell.Labeltext.text = [NSString stringWithFormat:@"%.01fK",config.storage.videoFreeStorage];
  104. }else if ([title isEqualToString:TS("picture_Capacity")]) {
  105. cell.Labeltext.text = [NSString stringWithFormat:@"%.01fK",config.storage.imgTotalStorage];
  106. }else if ([title isEqualToString:TS("picture_re_capacity")]) {
  107. cell.Labeltext.text = [NSString stringWithFormat:@"%.01fK",config.storage.imgFreeStorage];
  108. }else if ([title isEqualToString:TS("Is_Cover")]) { //普通设备只需要考虑这个清空配置就可以了
  109. cell.Labeltext.text = [NSString stringWithFormat:@"%@",config.storage.overWright];
  110. }else if ([title isEqualToString:TS("orginal_Is_Cover")]) { //这个只有一部分设备支持,例如:勇士相机等等
  111. cell.Labeltext.text = [NSString stringWithFormat:@"%@",config.storage.keyOverWrite];
  112. }else if ([title isEqualToString:TS("clean_storage")]) {
  113. }
  114. return cell;
  115. }
  116. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  117. NSString *titleStr = titleArray[indexPath.row];
  118. //初始化各个配置的item单元格
  119. ItemViewController *itemVC = [[ItemViewController alloc] init];
  120. [itemVC setTitle:titleStr];
  121. //循环录像配置和格式化配置不能同时设置,必须有先后顺序
  122. __weak typeof(self) weakSelf = self;
  123. itemVC.itemSelectStringBlock = ^(NSString *encodeString) {
  124. //itemVC的单元格点击回调,设置各种属性
  125. ItemTableviewCell *cell = [weakSelf.tableV cellForRowAtIndexPath:indexPath];
  126. cell.Labeltext.text = encodeString;
  127. if ([cell.textLabel.text isEqualToString:TS("Is_Cover")]) {
  128. [SVProgressHUD show];
  129. [config setOverWrightConfig:encodeString];
  130. }else if ([cell.textLabel.text isEqualToString:TS("orginal_Is_Cover")]) {
  131. [SVProgressHUD show]; //这个只有一部分设备支持,勇士类设备
  132. [config setKeyOverWrightConfig:encodeString];
  133. }else{
  134. return;
  135. }
  136. };
  137. //点击单元格之后进行分别赋值
  138. if ([titleStr isEqualToString:TS("Is_Cover")]) {
  139. NSMutableArray *array = [[config getEnableArray] mutableCopy];
  140. [itemVC setValueArray:array];
  141. }else if ([titleStr isEqualToString:TS("orginal_Is_Cover")]) {
  142. NSMutableArray *array = [[config getEnableArray] mutableCopy];
  143. [itemVC setValueArray:array];
  144. }else if ([titleStr isEqualToString:TS("clean_storage")]){
  145. //格式化
  146. [SVProgressHUD show];
  147. [config clearStorage];
  148. return;
  149. }
  150. //如果赋值成功,跳转到下一级界面
  151. [self.navigationController pushViewController:itemVC animated:YES];
  152. }
  153. #pragma mark - 界面和数据初始化
  154. - (void)configSubView {
  155. [self.view addSubview:self.tableV];
  156. }
  157. - (UITableView *)tableV {
  158. if (!tableV) {
  159. tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight ) style:UITableViewStylePlain];
  160. tableV.delegate = self;
  161. tableV.dataSource = self;
  162. [tableV registerClass:[ItemTableviewCell class] forCellReuseIdentifier:@"ItemTableviewCell"];
  163. }
  164. return tableV;
  165. }
  166. #pragma mark - 界面和数据初始化
  167. - (void)initDataSource {
  168. titleArray = (NSMutableArray*)@[TS("Total_Capacity"),TS("Residual_Capacity"),TS("video_Capacity"),TS("video_re_capacity"),TS("picture_Capacity"),TS("picture_re_capacity"),TS("Is_Cover"),TS("orginal_Is_Cover"),TS("clean_storage")];
  169. }
  170. - (void)didReceiveMemoryWarning {
  171. [super didReceiveMemoryWarning];
  172. // Dispose of any resources that can be recreated.
  173. }
  174. @end