Commit 7b1a65e3c40049652d38ed0d3c37090d4db25439

Authored by 王军波
1 parent 4eabe04e

点播点击

LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -267,6 +267,7 @@
267 267 D2EBC8851F02109C00F198FB /* LVCUGCPlayerLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8821F02109C00F198FB /* LVCUGCPlayerLoadingView.m */; };
268 268 D2EBC8881F0225D900F198FB /* LVCVodPlayerListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */; };
269 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 271 /* End PBXBuildFile section */
271 272  
272 273 /* Begin PBXContainerItemProxy section */
... ... @@ -828,6 +829,8 @@
828 829 D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCVodPlayerListController.m; sourceTree = "<group>"; };
829 830 D2EBC8891F02361600F198FB /* LVCUGCLiveListView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLiveListView.h; sourceTree = "<group>"; };
830 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 834 /* End PBXFileReference section */
832 835  
833 836 /* Begin PBXFrameworksBuildPhase section */
... ... @@ -2134,6 +2137,8 @@
2134 2137 children = (
2135 2138 D2EBC8861F0225D900F198FB /* LVCVodPlayerListController.h */,
2136 2139 D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */,
  2140 + D2EBC88C1F023AA400F198FB /* LVCVodPlayerController.h */,
  2141 + D2EBC88D1F023AA400F198FB /* LVCVodPlayerController.m */,
2137 2142 );
2138 2143 path = Controller;
2139 2144 sourceTree = "<group>";
... ... @@ -2471,6 +2476,7 @@
2471 2476 D2029C961E6EADE10027CD92 /* MBProgressHUD.m in Sources */,
2472 2477 D24F40921EFB727000833738 /* JBAutoRollTableView.m in Sources */,
2473 2478 810B65071E779B1F00133E15 /* ViewController+MASAdditions.m in Sources */,
  2479 + D2EBC88E1F023AA400F198FB /* LVCVodPlayerController.m in Sources */,
2474 2480 D2029C9A1E6EADE10027CD92 /* MJProperty.m in Sources */,
2475 2481 4BD856031EBACD530082061D /* AFNetworkActivityIndicatorManager.m in Sources */,
2476 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 10  
11 11 @interface LVCVodPlayerListController : UIViewController
12 12  
  13 +@property (nonatomic, assign)BOOL scrollToTop;
  14 +
  15 +- (void)isNeedToRefresh;
  16 +
13 17 @end
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerListController.m
... ... @@ -8,16 +8,20 @@
8 8  
9 9 #import "LVCVodPlayerListController.h"
10 10 #import "LVCTelevisionCell.h"
  11 +#import "LVCRequestFailedView.h"
  12 +#import "LVCVodPlayerController.h"
11 13  
12 14 static NSString *vodCellId = @"vodCellId";
13 15  
14   -@interface LVCVodPlayerListController ()<UITableViewDelegate, UITableViewDataSource> {
  16 +@interface LVCVodPlayerListController ()<UITableViewDelegate, UITableViewDataSource, LVCRequestFailedViewDelegate> {
15 17  
16 18 AFHTTPRequestOperation *_operation;
17 19 NSMutableArray *_programArrayM;
  20 + long long _timestamp;
18 21 }
19 22  
20 23 @property (nonatomic, strong)UITableView *tableView;
  24 +@property (nonatomic, strong) LVCRequestFailedView *failedView; //请求失败提示view
21 25  
22 26 @end
23 27  
... ... @@ -29,12 +33,18 @@ static NSString *vodCellId = @&quot;vodCellId&quot;;
29 33 self.navigationItem.title = @"点播";
30 34 self.view.backgroundColor = [UIColor whiteColor];
31 35 _programArrayM = [[NSMutableArray alloc] init];
32   - [self requestVodPlayerList];
  36 +
  37 + [self.tableView addSubview:self.failedView];
33 38 [self.view addSubview:self.tableView];
  39 +
  40 + _timestamp = [[self timestamp] longLongValue];
  41 + [self.tableView.header beginRefreshing];
34 42 }
35 43  
36 44 - (void)requestVodPlayerList {
37 45  
  46 + _failedView.hidden = YES;
  47 +
38 48 NSString *uid;
39 49 if ([UserTools isLogin]) {
40 50 uid = [UserInformationModel manager].uid;
... ... @@ -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 82 [self.tableView reloadData];
71 83  
72 84 } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
73 85  
74 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 97  
81 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 104 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
... ... @@ -100,6 +118,13 @@ static NSString *vodCellId = @&quot;vodCellId&quot;;
100 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 128 #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!
104 129 - (UITableView *)tableView {
105 130  
... ... @@ -108,12 +133,61 @@ static NSString *vodCellId = @&quot;vodCellId&quot;;
108 133 _tableView.dataSource = self;
109 134 _tableView.delegate = self;
110 135 _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  136 + _tableView.showsHorizontalScrollIndicator = NO;
  137 + _tableView.scrollsToTop = YES;
  138 + _tableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refresh)];
111 139  
112 140 [_tableView registerClass:[LVCTelevisionCell class] forCellReuseIdentifier:vodCellId];
113 141 }
114 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 191 #pragma mark ------------------------------ 分割线 ----------------------------------------------
118 192 - (NSDictionary *)addParameters:(NSDictionary *)dict {
119 193  
... ...