CloudAbilityViewController.mm 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //
  2. // CloudAbilityViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/12/27.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "CloudAbilityViewController.h"
  9. #import "CloudServerViewController.h"
  10. #import "PlayCloudVideoViewController.h"
  11. #import "ItemViewController.h"
  12. #import "ItemTableviewCell.h"
  13. #import "CloudAbilityConfig.h"
  14. @interface CloudAbilityViewController () <UITableViewDelegate,UITableViewDataSource,CloudStateRequestDelegate>
  15. {
  16. UITableView *itemTableView;
  17. NSMutableArray *titleArray;
  18. }
  19. @property (nonatomic, strong) CloudAbilityConfig * cloudConfig;
  20. @end
  21. @implementation CloudAbilityViewController
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. //初始化tableview数据
  25. [self initDataSource];
  26. [self configSubView];
  27. // 获取智能分析配置
  28. [self getCloudAbility];
  29. }
  30. - (void)viewWillDisappear:(BOOL)animated{
  31. //有加载状态、则取消加载
  32. if ([SVProgressHUD isVisible]){
  33. [SVProgressHUD dismiss];
  34. }
  35. }
  36. #pragma mark - 获取智能分析配置
  37. - (void)getCloudAbility {
  38. [SVProgressHUD showWithStatus:TS("")];
  39. if (_cloudConfig == nil) {
  40. _cloudConfig = [[CloudAbilityConfig alloc] init];
  41. _cloudConfig.delegate = self;
  42. }
  43. //调用获取云服务状态的接口
  44. [_cloudConfig getCloudAbilityServer];
  45. //获取云视频和云图片的状态
  46. [_cloudConfig getVideoOrPicAbilityServer];
  47. }
  48. #pragma mark 获取云服务能力级回调
  49. - (void)getCloudAbilityResult:(NSInteger)result {
  50. if (result >=0) {
  51. //成功,刷新界面数据
  52. [self.itemTableView reloadData];
  53. [SVProgressHUD dismiss];
  54. }else{
  55. [MessageUI ShowErrorInt:(int)result];
  56. }
  57. }
  58. #pragma mark 获取云视频和云图片能力级回调
  59. -(void)getVideoOrPicAbilityResult:(NSInteger)result {
  60. if (result >=0) {
  61. //成功,刷新界面数据
  62. [self.itemTableView reloadData];
  63. [SVProgressHUD dismiss];
  64. }else{
  65. [MessageUI ShowErrorInt:(int)result];
  66. }
  67. }
  68. #pragma mark 获取智能分析代理回调
  69. - (void)getAnalyzeConfigResult:(NSInteger)result {
  70. if (result >0) {
  71. //成功,刷新界面数据
  72. [self.itemTableView reloadData];
  73. [SVProgressHUD dismiss];
  74. }else{
  75. [MessageUI ShowErrorInt:(int)result];
  76. }
  77. }
  78. #pragma mark - tableView代理方法
  79. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  80. return titleArray.count;
  81. }
  82. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  83. ItemTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemTableviewCell"];
  84. if (!cell) {
  85. cell = [[ItemTableviewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ItemTableviewCell"];
  86. }
  87. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  88. NSString *title = [titleArray objectAtIndex:indexPath.row];
  89. cell.textLabel.text = title;
  90. if ([title isEqualToString:TS("Cloud_storage")]) {
  91. cell.Labeltext.text = [_cloudConfig getCloudState];
  92. }
  93. if ([title isEqualToString:TS("search_Video")]) {
  94. cell.Labeltext.text = [_cloudConfig getVideoEnable];
  95. }
  96. if ([title isEqualToString:TS("search_picture")]) {
  97. cell.Labeltext.text = [_cloudConfig getPicEnable];
  98. }
  99. return cell;
  100. }
  101. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  102. NSString *titleStr = titleArray[indexPath.row];
  103. //点击单元格之后进行分别赋值
  104. if ([titleStr isEqualToString:TS("Cloud_storage")]) {
  105. //云服务
  106. if ([[_cloudConfig getCloudState] isEqualToString:TS("not_suport")]) {
  107. return; //不支持,直接return
  108. }else{
  109. //跳入云服务页面
  110. CloudServerViewController *cloudServerVC = [[CloudServerViewController alloc] init];
  111. [self.navigationController pushViewController:cloudServerVC animated:YES];
  112. }
  113. }else if ([titleStr isEqualToString:TS("search_Video")]) {
  114. //云视频
  115. if ([[_cloudConfig getVideoEnable] isEqualToString:TS("not_opened")]) {
  116. return;
  117. }else {
  118. CloudVideoViewController *cloudVideoVC = [[CloudVideoViewController alloc] init];
  119. [self.navigationController pushViewController:cloudVideoVC animated:YES];
  120. }
  121. }else if ([titleStr isEqualToString:TS("search_picture")]) {
  122. //云图片
  123. if ([[_cloudConfig getVideoEnable] isEqualToString:TS("not_opened")]) {
  124. return;
  125. }else {
  126. CloudPhotoViewController *cloudPhotoVC = [[CloudPhotoViewController alloc] init];
  127. [self.navigationController pushViewController:cloudPhotoVC animated:YES];
  128. }
  129. }else if ([titleStr isEqualToString:TS("Cloud_video")]) {
  130. //云视频播放
  131. PlayCloudVideoViewController *playCloudVC = [[PlayCloudVideoViewController alloc] init];
  132. [self.navigationController pushViewController:playCloudVC animated:YES];
  133. }else{
  134. return;
  135. }
  136. }
  137. #pragma mark - 界面和数据初始化
  138. - (void)configSubView {
  139. self.navigationItem.title = TS("Cloud_storage");
  140. [self.view addSubview:self.itemTableView];
  141. }
  142. - (UITableView *)itemTableView {
  143. if (!itemTableView) {
  144. itemTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight ) style:UITableViewStylePlain];
  145. itemTableView.delegate = self;
  146. itemTableView.dataSource = self;
  147. [itemTableView registerClass:[ItemTableviewCell class] forCellReuseIdentifier:@"ItemTableviewCell"];
  148. }
  149. return itemTableView;
  150. }
  151. #pragma mark - 界面和数据初始化
  152. - (void)initDataSource {
  153. titleArray = (NSMutableArray*)@[TS("Cloud_storage"),TS("search_Video"),TS("search_picture"),TS("Cloud_video")];
  154. }
  155. @end