Commit 7b1a65e3c40049652d38ed0d3c37090d4db25439

Authored by 王军波
1 parent 4eabe04e

点播点击

LiveVideoCloud.xcodeproj/project.pbxproj
@@ -267,6 +267,7 @@ @@ -267,6 +267,7 @@
267 D2EBC8851F02109C00F198FB /* LVCUGCPlayerLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8821F02109C00F198FB /* LVCUGCPlayerLoadingView.m */; }; 267 D2EBC8851F02109C00F198FB /* LVCUGCPlayerLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8821F02109C00F198FB /* LVCUGCPlayerLoadingView.m */; };
268 D2EBC8881F0225D900F198FB /* LVCVodPlayerListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */; }; 268 D2EBC8881F0225D900F198FB /* LVCVodPlayerListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */; };
269 D2EBC88B1F02361600F198FB /* LVCUGCLiveListView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC88A1F02361600F198FB /* LVCUGCLiveListView.m */; }; 269 D2EBC88B1F02361600F198FB /* LVCUGCLiveListView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC88A1F02361600F198FB /* LVCUGCLiveListView.m */; };
  270 + D2EBC88E1F023AA400F198FB /* LVCVodPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC88D1F023AA400F198FB /* LVCVodPlayerController.m */; };
270 /* End PBXBuildFile section */ 271 /* End PBXBuildFile section */
271 272
272 /* Begin PBXContainerItemProxy section */ 273 /* Begin PBXContainerItemProxy section */
@@ -828,6 +829,8 @@ @@ -828,6 +829,8 @@
828 D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCVodPlayerListController.m; sourceTree = "<group>"; }; 829 D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCVodPlayerListController.m; sourceTree = "<group>"; };
829 D2EBC8891F02361600F198FB /* LVCUGCLiveListView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLiveListView.h; sourceTree = "<group>"; }; 830 D2EBC8891F02361600F198FB /* LVCUGCLiveListView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLiveListView.h; sourceTree = "<group>"; };
830 D2EBC88A1F02361600F198FB /* LVCUGCLiveListView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLiveListView.m; sourceTree = "<group>"; }; 831 D2EBC88A1F02361600F198FB /* LVCUGCLiveListView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLiveListView.m; sourceTree = "<group>"; };
  832 + D2EBC88C1F023AA400F198FB /* LVCVodPlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCVodPlayerController.h; sourceTree = "<group>"; };
  833 + D2EBC88D1F023AA400F198FB /* LVCVodPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCVodPlayerController.m; sourceTree = "<group>"; };
831 /* End PBXFileReference section */ 834 /* End PBXFileReference section */
832 835
833 /* Begin PBXFrameworksBuildPhase section */ 836 /* Begin PBXFrameworksBuildPhase section */
@@ -2134,6 +2137,8 @@ @@ -2134,6 +2137,8 @@
2134 children = ( 2137 children = (
2135 D2EBC8861F0225D900F198FB /* LVCVodPlayerListController.h */, 2138 D2EBC8861F0225D900F198FB /* LVCVodPlayerListController.h */,
2136 D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */, 2139 D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */,
  2140 + D2EBC88C1F023AA400F198FB /* LVCVodPlayerController.h */,
  2141 + D2EBC88D1F023AA400F198FB /* LVCVodPlayerController.m */,
2137 ); 2142 );
2138 path = Controller; 2143 path = Controller;
2139 sourceTree = "<group>"; 2144 sourceTree = "<group>";
@@ -2471,6 +2476,7 @@ @@ -2471,6 +2476,7 @@
2471 D2029C961E6EADE10027CD92 /* MBProgressHUD.m in Sources */, 2476 D2029C961E6EADE10027CD92 /* MBProgressHUD.m in Sources */,
2472 D24F40921EFB727000833738 /* JBAutoRollTableView.m in Sources */, 2477 D24F40921EFB727000833738 /* JBAutoRollTableView.m in Sources */,
2473 810B65071E779B1F00133E15 /* ViewController+MASAdditions.m in Sources */, 2478 810B65071E779B1F00133E15 /* ViewController+MASAdditions.m in Sources */,
  2479 + D2EBC88E1F023AA400F198FB /* LVCVodPlayerController.m in Sources */,
2474 D2029C9A1E6EADE10027CD92 /* MJProperty.m in Sources */, 2480 D2029C9A1E6EADE10027CD92 /* MJProperty.m in Sources */,
2475 4BD856031EBACD530082061D /* AFNetworkActivityIndicatorManager.m in Sources */, 2481 4BD856031EBACD530082061D /* AFNetworkActivityIndicatorManager.m in Sources */,
2476 4BD855CD1EBAC4B70082061D /* CNLiveKeychainWrapper.m in Sources */, 2482 4BD855CD1EBAC4B70082061D /* CNLiveKeychainWrapper.m in Sources */,
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerController.h 0 → 100644
  1 +//
  2 +// LVCVodPlayerController.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/6/27.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "BaseViewController.h"
  10 +
  11 +@interface LVCVodPlayerController : BaseViewController
  12 +
  13 +@end
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerController.m 0 → 100644
  1 +//
  2 +// LVCVodPlayerController.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/6/27.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCVodPlayerController.h"
  10 +
  11 +@interface LVCVodPlayerController ()
  12 +
  13 +@end
  14 +
  15 +@implementation LVCVodPlayerController
  16 +
  17 +- (void)viewDidLoad {
  18 + [super viewDidLoad];
  19 +
  20 + self.view.backgroundColor = [UIColor whiteColor];
  21 +}
  22 +
  23 +- (void)didReceiveMemoryWarning {
  24 + [super didReceiveMemoryWarning];
  25 + // Dispose of any resources that can be recreated.
  26 +}
  27 +
  28 +@end
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerListController.h
@@ -10,4 +10,8 @@ @@ -10,4 +10,8 @@
10 10
11 @interface LVCVodPlayerListController : UIViewController 11 @interface LVCVodPlayerListController : UIViewController
12 12
  13 +@property (nonatomic, assign)BOOL scrollToTop;
  14 +
  15 +- (void)isNeedToRefresh;
  16 +
13 @end 17 @end
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerListController.m
@@ -8,16 +8,20 @@ @@ -8,16 +8,20 @@
8 8
9 #import "LVCVodPlayerListController.h" 9 #import "LVCVodPlayerListController.h"
10 #import "LVCTelevisionCell.h" 10 #import "LVCTelevisionCell.h"
  11 +#import "LVCRequestFailedView.h"
  12 +#import "LVCVodPlayerController.h"
11 13
12 static NSString *vodCellId = @"vodCellId"; 14 static NSString *vodCellId = @"vodCellId";
13 15
14 -@interface LVCVodPlayerListController ()<UITableViewDelegate, UITableViewDataSource> { 16 +@interface LVCVodPlayerListController ()<UITableViewDelegate, UITableViewDataSource, LVCRequestFailedViewDelegate> {
15 17
16 AFHTTPRequestOperation *_operation; 18 AFHTTPRequestOperation *_operation;
17 NSMutableArray *_programArrayM; 19 NSMutableArray *_programArrayM;
  20 + long long _timestamp;
18 } 21 }
19 22
20 @property (nonatomic, strong)UITableView *tableView; 23 @property (nonatomic, strong)UITableView *tableView;
  24 +@property (nonatomic, strong) LVCRequestFailedView *failedView; //请求失败提示view
21 25
22 @end 26 @end
23 27
@@ -29,12 +33,18 @@ static NSString *vodCellId = @&quot;vodCellId&quot;; @@ -29,12 +33,18 @@ static NSString *vodCellId = @&quot;vodCellId&quot;;
29 self.navigationItem.title = @"点播"; 33 self.navigationItem.title = @"点播";
30 self.view.backgroundColor = [UIColor whiteColor]; 34 self.view.backgroundColor = [UIColor whiteColor];
31 _programArrayM = [[NSMutableArray alloc] init]; 35 _programArrayM = [[NSMutableArray alloc] init];
32 - [self requestVodPlayerList]; 36 +
  37 + [self.tableView addSubview:self.failedView];
33 [self.view addSubview:self.tableView]; 38 [self.view addSubview:self.tableView];
  39 +
  40 + _timestamp = [[self timestamp] longLongValue];
  41 + [self.tableView.header beginRefreshing];
34 } 42 }
35 43
36 - (void)requestVodPlayerList { 44 - (void)requestVodPlayerList {
37 45
  46 + _failedView.hidden = YES;
  47 +
38 NSString *uid; 48 NSString *uid;
39 if ([UserTools isLogin]) { 49 if ([UserTools isLogin]) {
40 uid = [UserInformationModel manager].uid; 50 uid = [UserInformationModel manager].uid;
@@ -67,11 +77,18 @@ static NSString *vodCellId = @&quot;vodCellId&quot;; @@ -67,11 +77,18 @@ static NSString *vodCellId = @&quot;vodCellId&quot;;
67 } 77 }
68 } 78 }
69 } 79 }
  80 + _timestamp = [[self timestamp] longLongValue];
  81 + [self.tableView.header endRefreshing];
70 [self.tableView reloadData]; 82 [self.tableView reloadData];
71 83
72 } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 84 } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
73 85
74 NSLog(@"点播列表请求失败!"); 86 NSLog(@"点播列表请求失败!");
  87 + _timestamp = [[self timestamp] longLongValue];
  88 + [self.tableView.header endRefreshing];
  89 + if (_programArrayM.count == 0) {
  90 + _failedView.hidden = NO;
  91 + }
75 }]; 92 }];
76 } 93 }
77 94
@@ -80,7 +97,8 @@ static NSString *vodCellId = @&quot;vodCellId&quot;; @@ -80,7 +97,8 @@ static NSString *vodCellId = @&quot;vodCellId&quot;;
80 97
81 [tableView deselectRowAtIndexPath:indexPath animated:NO]; 98 [tableView deselectRowAtIndexPath:indexPath animated:NO];
82 99
83 - 100 + LVCVodPlayerController *vc = [[LVCVodPlayerController alloc] init];
  101 + [self.navigationController pushViewController:vc animated:YES];
84 } 102 }
85 103
86 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 104 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -100,6 +118,13 @@ static NSString *vodCellId = @&quot;vodCellId&quot;; @@ -100,6 +118,13 @@ static NSString *vodCellId = @&quot;vodCellId&quot;;
100 return cell; 118 return cell;
101 } 119 }
102 120
  121 +#pragma mark - LVCRequestFailedViewDelegate
  122 +- (void)reloadDataWithView:(LVCRequestFailedView *)view
  123 +{
  124 + [self.tableView.header beginRefreshing];
  125 + [self requestVodPlayerList];
  126 +}
  127 +
103 #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!! 128 #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!
104 - (UITableView *)tableView { 129 - (UITableView *)tableView {
105 130
@@ -108,12 +133,61 @@ static NSString *vodCellId = @&quot;vodCellId&quot;; @@ -108,12 +133,61 @@ static NSString *vodCellId = @&quot;vodCellId&quot;;
108 _tableView.dataSource = self; 133 _tableView.dataSource = self;
109 _tableView.delegate = self; 134 _tableView.delegate = self;
110 _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 135 _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  136 + _tableView.showsHorizontalScrollIndicator = NO;
  137 + _tableView.scrollsToTop = YES;
  138 + _tableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refresh)];
111 139
112 [_tableView registerClass:[LVCTelevisionCell class] forCellReuseIdentifier:vodCellId]; 140 [_tableView registerClass:[LVCTelevisionCell class] forCellReuseIdentifier:vodCellId];
113 } 141 }
114 return _tableView; 142 return _tableView;
115 } 143 }
116 144
  145 +- (LVCRequestFailedView *)failedView
  146 +{
  147 + if (!_failedView) {
  148 + _failedView = [[LVCRequestFailedView alloc] initWithFrame:CGRectMake(0, 0, 150, 100) words:@"您的网络不太顺畅哦~"];
  149 + _failedView.center = self.tableView.center;
  150 + _failedView.delegate = self;
  151 + _failedView.hidden = YES;
  152 + }
  153 + return _failedView;
  154 +}
  155 +
  156 +#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  157 +- (void)refresh {
  158 +
  159 + [self requestVodPlayerList];
  160 +}
  161 +
  162 +- (NSString *)timestamp {
  163 +
  164 + NSString *stamp = @"";
  165 +
  166 + stamp = [NSString stringWithFormat:@"%.3f", [[NSDate date] timeIntervalSince1970]];
  167 + stamp = [stamp stringByReplacingOccurrencesOfString:@"." withString:@""];
  168 +
  169 + return stamp;
  170 +}
  171 +
  172 +- (void)autoRefresh {
  173 +
  174 + [self requestVodPlayerList];
  175 +}
  176 +
  177 +- (void)isNeedToRefresh {
  178 +
  179 + long long timestamp = [[self timestamp] longLongValue];
  180 + if (timestamp-_timestamp > 180000) {
  181 + [self.tableView.header beginRefreshing];
  182 + }
  183 +}
  184 +
  185 +- (void)setScrollToTop:(BOOL)scrollToTop {
  186 +
  187 + _scrollToTop = scrollToTop;
  188 + self.tableView.scrollsToTop = scrollToTop;
  189 +}
  190 +
117 #pragma mark ------------------------------ 分割线 ---------------------------------------------- 191 #pragma mark ------------------------------ 分割线 ----------------------------------------------
118 - (NSDictionary *)addParameters:(NSDictionary *)dict { 192 - (NSDictionary *)addParameters:(NSDictionary *)dict {
119 193