Commit cdf29cb7ca6e5ffa744400cc880a0a3408e1c8b3

Authored by zhangxiaowen
1 parent 0b99cbcb

no message

CNLiveCollectionModule/Classes/Controller/CNLiveCollectionController.m
@@ -8,12 +8,11 @@ @@ -8,12 +8,11 @@
8 8
9 #import "CNLiveCollectionController.h" 9 #import "CNLiveCollectionController.h"
10 #import "QMUIKit.h" 10 #import "QMUIKit.h"
11 -#import "MJExtension.h" 11 +
12 #import <Masonry/Masonry.h> 12 #import <Masonry/Masonry.h>
13 #import <SDWebImage/SDWebImage.h> 13 #import <SDWebImage/SDWebImage.h>
14 #import "CNLiveCategory.h" 14 #import "CNLiveCategory.h"
15 -#import "CNLiveNetworking.h"  
16 -#import "CNLiveEnvironment.h" 15 +
17 #import "CNUserInfoManager.h" 16 #import "CNUserInfoManager.h"
18 17
19 #import "CNLiveRefreshHeader.h" 18 #import "CNLiveRefreshHeader.h"
@@ -31,6 +30,7 @@ @@ -31,6 +30,7 @@
31 @property (nonatomic, strong) NSMutableArray *data; 30 @property (nonatomic, strong) NSMutableArray *data;
32 31
33 @property (nonatomic, assign) NSInteger pageNo; 32 @property (nonatomic, assign) NSInteger pageNo;
  33 +@property (nonatomic, assign) NSInteger pageSize;
34 @property (nonatomic, assign) BOOL isRefreshing; 34 @property (nonatomic, assign) BOOL isRefreshing;
35 35
36 @end 36 @end
@@ -42,7 +42,8 @@ static const CGFloat timeValue = 1.5; @@ -42,7 +42,8 @@ static const CGFloat timeValue = 1.5;
42 - (void)loadData{ 42 - (void)loadData{
43 [QMUITips showLoadingInView:self.view]; 43 [QMUITips showLoadingInView:self.view];
44 __weak typeof(self) weakSelf = self; 44 __weak typeof(self) weakSelf = self;
45 - [CNLiveCollectionRequest getCollectionList:CNUserShareModel.uid pageNo:[NSString stringWithFormat:@"%ld",_pageNo] block:^(BOOL isSuccess, NSArray * _Nonnull array, NSError * _Nonnull error) { 45 +
  46 + [CNLiveCollectionRequest getCollectionList:[NSString stringWithFormat:@"%ld",_pageNo] pageSize:[NSString stringWithFormat:@"%ld",_pageSize] block:^(BOOL isSuccess, NSArray * _Nonnull array, NSError * _Nonnull error) {
46 __strong typeof(weakSelf) strongSelf = weakSelf; 47 __strong typeof(weakSelf) strongSelf = weakSelf;
47 if(!strongSelf) return ; 48 if(!strongSelf) return ;
48 [QMUITips hideAllTipsInView:strongSelf.view]; 49 [QMUITips hideAllTipsInView:strongSelf.view];
@@ -69,7 +70,7 @@ static const CGFloat timeValue = 1.5; @@ -69,7 +70,7 @@ static const CGFloat timeValue = 1.5;
69 strongSelf.isRefreshing = NO; 70 strongSelf.isRefreshing = NO;
70 strongSelf.pageNo++; 71 strongSelf.pageNo++;
71 [strongSelf.data addObjectsFromArray:array]; 72 [strongSelf.data addObjectsFromArray:array];
72 - if (array.count < 10) { 73 + if (array.count < strongSelf.pageSize) {
73 [strongSelf.tableView.mj_footer endRefreshingWithNoMoreData]; 74 [strongSelf.tableView.mj_footer endRefreshingWithNoMoreData];
74 75
75 } else { 76 } else {
@@ -85,13 +86,13 @@ static const CGFloat timeValue = 1.5; @@ -85,13 +86,13 @@ static const CGFloat timeValue = 1.5;
85 } 86 }
86 strongSelf.tableView.mj_footer.hidden = self.data.count == 0; 87 strongSelf.tableView.mj_footer.hidden = self.data.count == 0;
87 [strongSelf.tableView reloadData]; 88 [strongSelf.tableView reloadData];
  89 +
88 }]; 90 }];
89 91
90 } 92 }
91 93
92 - (void)loadMoreData{ 94 - (void)loadMoreData{
93 if(!_isRefreshing){ 95 if(!_isRefreshing){
94 - _isRefreshing = YES;  
95 [self loadData]; 96 [self loadData];
96 } 97 }
97 } 98 }
@@ -109,8 +110,9 @@ static const CGFloat timeValue = 1.5; @@ -109,8 +110,9 @@ static const CGFloat timeValue = 1.5;
109 else { 110 else {
110 self.automaticallyAdjustsScrollViewInsets = NO; 111 self.automaticallyAdjustsScrollViewInsets = NO;
111 } 112 }
112 - _pageNo = 1;  
113 _isRefreshing = NO; 113 _isRefreshing = NO;
  114 + _pageNo = 1;
  115 + _pageSize = 10;
114 [self loadData]; 116 [self loadData];
115 [self createSubViews]; 117 [self createSubViews];
116 } 118 }
@@ -211,7 +213,7 @@ static const CGFloat timeValue = 1.5; @@ -211,7 +213,7 @@ static const CGFloat timeValue = 1.5;
211 _tableView.estimatedSectionFooterHeight = 0; 213 _tableView.estimatedSectionFooterHeight = 0;
212 [_tableView registerClass:[CNLiveCollectionCell class] forCellReuseIdentifier:kCNLiveCollectionCell]; 214 [_tableView registerClass:[CNLiveCollectionCell class] forCellReuseIdentifier:kCNLiveCollectionCell];
213 _tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingBlock:^{ 215 _tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingBlock:^{
214 - _pageNo = 1; 216 + self.pageNo = 1;
215 [self loadData]; 217 [self loadData];
216 218
217 }]; 219 }];
CNLiveCollectionModule/Classes/Model/CNLiveCollectionRequest.h
@@ -8,14 +8,14 @@ @@ -8,14 +8,14 @@
8 8
9 #import <Foundation/Foundation.h> 9 #import <Foundation/Foundation.h>
10 10
11 -NS_ASSUME_NONNULL_BEGIN  
12 -  
13 typedef void(^CollectionListBlock)(BOOL isSuccess, NSArray *array, NSError *error); 11 typedef void(^CollectionListBlock)(BOOL isSuccess, NSArray *array, NSError *error);
14 typedef void(^CancelCollectionBlock)(BOOL isSuccess, NSError *error); 12 typedef void(^CancelCollectionBlock)(BOOL isSuccess, NSError *error);
15 13
  14 +NS_ASSUME_NONNULL_BEGIN
  15 +
16 @interface CNLiveCollectionRequest : NSObject 16 @interface CNLiveCollectionRequest : NSObject
17 17
18 -+ (void)getCollectionList:(NSString *)ID pageNo:(NSString *)pageNo block:(CollectionListBlock)block; 18 ++ (void)getCollectionList:(NSString *)pageNo pageSize:(NSString *)pageSize block:(CollectionListBlock)block;
19 19
20 + (void)cancelCollection:(NSString *)ID block:(CancelCollectionBlock)block; 20 + (void)cancelCollection:(NSString *)ID block:(CancelCollectionBlock)block;
21 21
CNLiveCollectionModule/Classes/Model/CNLiveCollectionRequest.m
@@ -17,13 +17,13 @@ @@ -17,13 +17,13 @@
17 17
18 @implementation CNLiveCollectionRequest 18 @implementation CNLiveCollectionRequest
19 19
20 -+ (void)getCollectionList:(NSString *)ID pageNo:(NSString *)pageNo block:(CollectionListBlock)block{ 20 ++ (void)getCollectionList:(NSString *)pageNo pageSize:(NSString *)pageSize block:(CollectionListBlock)block{
21 NSDictionary *params = @{ 21 NSDictionary *params = @{
22 - @"pageSize":@"10", 22 + @"pageSize":pageSize,
23 @"pageNo":pageNo, 23 @"pageNo":pageNo,
24 @"appId":AppId, 24 @"appId":AppId,
25 @"plat":@"i", 25 @"plat":@"i",
26 - @"sid":ID}; 26 + @"sid":CNUserShareModel.uid};
27 [CNLiveNetworking setAllowRequestDefaultArgument:YES]; 27 [CNLiveNetworking setAllowRequestDefaultArgument:YES];
28 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNDarenCollectListDataSourceUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { 28 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNDarenCollectListDataSourceUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
29 if (responseObject&&[responseObject isKindOfClass:[NSDictionary class]]) { 29 if (responseObject&&[responseObject isKindOfClass:[NSDictionary class]]) {