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 | 12 | #import "LVCUGCLiveListModel.h" |
| 13 | 13 | #import "LVCUGCLivePlayerModel.h" |
| 14 | 14 | #import "LVCUGCLivePlayerController.h" |
| 15 | +#import "LVCRequestFailedView.h" | |
| 15 | 16 | |
| 16 | 17 | static NSString *cellId = @"cellId"; |
| 17 | 18 | |
| 18 | -@interface LVCUGCLiveListView()<UICollectionViewDelegate, UICollectionViewDataSource> { | |
| 19 | +@interface LVCUGCLiveListView()<UICollectionViewDelegate, UICollectionViewDataSource, LVCRequestFailedViewDelegate> { | |
| 19 | 20 | |
| 20 | 21 | NSMutableArray *_arrayM; |
| 21 | 22 | long long _timestamp; |
| ... | ... | @@ -23,9 +24,7 @@ static NSString *cellId = @"cellId"; |
| 23 | 24 | |
| 24 | 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 | 29 | @end |
| 31 | 30 | |
| ... | ... | @@ -39,8 +38,8 @@ static NSString *cellId = @"cellId"; |
| 39 | 38 | |
| 40 | 39 | _arrayM = [[NSMutableArray alloc] init]; |
| 41 | 40 | |
| 41 | + [self.collectionView addSubview:self.failedView]; | |
| 42 | 42 | [self addSubview:self.collectionView]; |
| 43 | - | |
| 44 | 43 | _timestamp = [[self timestamp] longLongValue]; |
| 45 | 44 | [self.collectionView.header beginRefreshing]; |
| 46 | 45 | } |
| ... | ... | @@ -49,12 +48,18 @@ static NSString *cellId = @"cellId"; |
| 49 | 48 | |
| 50 | 49 | - (void)loadData { |
| 51 | 50 | |
| 51 | + _failedView.hidden = YES; | |
| 52 | + | |
| 52 | 53 | [LiveLIstService getLiveListWithHandler:^(id data, NSError *error) { |
| 53 | 54 | |
| 54 | 55 | if (error) { |
| 55 | 56 | NSLog(@"失败===>error:%@",error); |
| 56 | 57 | |
| 57 | 58 | _timestamp = [[self timestamp] longLongValue]; |
| 59 | + [self.collectionView.header endRefreshing]; | |
| 60 | + if (_arrayM.count == 0) { | |
| 61 | + _failedView.hidden = NO; | |
| 62 | + } | |
| 58 | 63 | return ; |
| 59 | 64 | } |
| 60 | 65 | NSLog(@"成功===>data%@",data); |
| ... | ... | @@ -85,8 +90,6 @@ static NSString *cellId = @"cellId"; |
| 85 | 90 | |
| 86 | 91 | LVCUGCLivePlayerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]; |
| 87 | 92 | |
| 88 | - NSLog(@"cell ------> %@",cell); | |
| 89 | - | |
| 90 | 93 | LVCUGCLivePlayerModel *model = _arrayM[indexPath.row]; |
| 91 | 94 | cell.model = model; |
| 92 | 95 | |
| ... | ... | @@ -102,6 +105,13 @@ static NSString *cellId = @"cellId"; |
| 102 | 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 | 115 | #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 106 | 116 | - (UICollectionView *)collectionView { |
| 107 | 117 | |
| ... | ... | @@ -122,6 +132,17 @@ static NSString *cellId = @"cellId"; |
| 122 | 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 | 146 | #pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 126 | 147 | - (void)refresh { |
| 127 | 148 | ... | ... |