Commit 14ba2e3c3af4367de6c275ab8ad59a198b869000
1 parent
0e4a3cb4
加载数据失败重试按钮
Showing
1 changed file
with
28 additions
and
7 deletions
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLiveListView.m
| @@ -12,10 +12,11 @@ | @@ -12,10 +12,11 @@ | ||
| 12 | #import "LVCUGCLiveListModel.h" | 12 | #import "LVCUGCLiveListModel.h" |
| 13 | #import "LVCUGCLivePlayerModel.h" | 13 | #import "LVCUGCLivePlayerModel.h" |
| 14 | #import "LVCUGCLivePlayerController.h" | 14 | #import "LVCUGCLivePlayerController.h" |
| 15 | +#import "LVCRequestFailedView.h" | ||
| 15 | 16 | ||
| 16 | static NSString *cellId = @"cellId"; | 17 | static NSString *cellId = @"cellId"; |
| 17 | 18 | ||
| 18 | -@interface LVCUGCLiveListView()<UICollectionViewDelegate, UICollectionViewDataSource> { | 19 | +@interface LVCUGCLiveListView()<UICollectionViewDelegate, UICollectionViewDataSource, LVCRequestFailedViewDelegate> { |
| 19 | 20 | ||
| 20 | NSMutableArray *_arrayM; | 21 | NSMutableArray *_arrayM; |
| 21 | long long _timestamp; | 22 | long long _timestamp; |
| @@ -23,9 +24,7 @@ static NSString *cellId = @"cellId"; | @@ -23,9 +24,7 @@ static NSString *cellId = @"cellId"; | ||
| 23 | 24 | ||
| 24 | @property (nonatomic, strong) UICollectionView *collectionView; | 25 | @property (nonatomic, strong) UICollectionView *collectionView; |
| 25 | 26 | ||
| 26 | -@property (nonatomic, strong)UIButton *reloadBtn; | ||
| 27 | -@property (nonatomic, strong)UIImageView *reloadImg; | ||
| 28 | -@property (nonatomic, strong)UILabel *reloadLab; | 27 | +@property (nonatomic, strong) LVCRequestFailedView *failedView; //请求失败提示view |
| 29 | 28 | ||
| 30 | @end | 29 | @end |
| 31 | 30 | ||
| @@ -39,8 +38,8 @@ static NSString *cellId = @"cellId"; | @@ -39,8 +38,8 @@ static NSString *cellId = @"cellId"; | ||
| 39 | 38 | ||
| 40 | _arrayM = [[NSMutableArray alloc] init]; | 39 | _arrayM = [[NSMutableArray alloc] init]; |
| 41 | 40 | ||
| 41 | + [self.collectionView addSubview:self.failedView]; | ||
| 42 | [self addSubview:self.collectionView]; | 42 | [self addSubview:self.collectionView]; |
| 43 | - | ||
| 44 | _timestamp = [[self timestamp] longLongValue]; | 43 | _timestamp = [[self timestamp] longLongValue]; |
| 45 | [self.collectionView.header beginRefreshing]; | 44 | [self.collectionView.header beginRefreshing]; |
| 46 | } | 45 | } |
| @@ -49,12 +48,18 @@ static NSString *cellId = @"cellId"; | @@ -49,12 +48,18 @@ static NSString *cellId = @"cellId"; | ||
| 49 | 48 | ||
| 50 | - (void)loadData { | 49 | - (void)loadData { |
| 51 | 50 | ||
| 51 | + _failedView.hidden = YES; | ||
| 52 | + | ||
| 52 | [LiveLIstService getLiveListWithHandler:^(id data, NSError *error) { | 53 | [LiveLIstService getLiveListWithHandler:^(id data, NSError *error) { |
| 53 | 54 | ||
| 54 | if (error) { | 55 | if (error) { |
| 55 | NSLog(@"失败===>error:%@",error); | 56 | NSLog(@"失败===>error:%@",error); |
| 56 | 57 | ||
| 57 | _timestamp = [[self timestamp] longLongValue]; | 58 | _timestamp = [[self timestamp] longLongValue]; |
| 59 | + [self.collectionView.header endRefreshing]; | ||
| 60 | + if (_arrayM.count == 0) { | ||
| 61 | + _failedView.hidden = NO; | ||
| 62 | + } | ||
| 58 | return ; | 63 | return ; |
| 59 | } | 64 | } |
| 60 | NSLog(@"成功===>data%@",data); | 65 | NSLog(@"成功===>data%@",data); |
| @@ -85,8 +90,6 @@ static NSString *cellId = @"cellId"; | @@ -85,8 +90,6 @@ static NSString *cellId = @"cellId"; | ||
| 85 | 90 | ||
| 86 | LVCUGCLivePlayerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]; | 91 | LVCUGCLivePlayerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]; |
| 87 | 92 | ||
| 88 | - NSLog(@"cell ------> %@",cell); | ||
| 89 | - | ||
| 90 | LVCUGCLivePlayerModel *model = _arrayM[indexPath.row]; | 93 | LVCUGCLivePlayerModel *model = _arrayM[indexPath.row]; |
| 91 | cell.model = model; | 94 | cell.model = model; |
| 92 | 95 | ||
| @@ -102,6 +105,13 @@ static NSString *cellId = @"cellId"; | @@ -102,6 +105,13 @@ static NSString *cellId = @"cellId"; | ||
| 102 | [self.viewController.navigationController pushViewController:player animated:YES]; | 105 | [self.viewController.navigationController pushViewController:player animated:YES]; |
| 103 | } | 106 | } |
| 104 | 107 | ||
| 108 | +#pragma mark - LVCRequestFailedViewDelegate | ||
| 109 | +- (void)reloadDataWithView:(LVCRequestFailedView *)view | ||
| 110 | +{ | ||
| 111 | + [self.collectionView.header beginRefreshing]; | ||
| 112 | + [self loadData]; | ||
| 113 | +} | ||
| 114 | + | ||
| 105 | #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 115 | #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 106 | - (UICollectionView *)collectionView { | 116 | - (UICollectionView *)collectionView { |
| 107 | 117 | ||
| @@ -122,6 +132,17 @@ static NSString *cellId = @"cellId"; | @@ -122,6 +132,17 @@ static NSString *cellId = @"cellId"; | ||
| 122 | return _collectionView; | 132 | return _collectionView; |
| 123 | } | 133 | } |
| 124 | 134 | ||
| 135 | +- (LVCRequestFailedView *)failedView | ||
| 136 | +{ | ||
| 137 | + if (!_failedView) { | ||
| 138 | + _failedView = [[LVCRequestFailedView alloc] initWithFrame:CGRectMake(0, 0, 150, 100) words:@"您的网络不太顺畅哦~"]; | ||
| 139 | + _failedView.center = self.collectionView.center; | ||
| 140 | + _failedView.delegate = self; | ||
| 141 | + _failedView.hidden = YES; | ||
| 142 | + } | ||
| 143 | + return _failedView; | ||
| 144 | +} | ||
| 145 | + | ||
| 125 | #pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 146 | #pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 126 | - (void)refresh { | 147 | - (void)refresh { |
| 127 | 148 |