Commit cdf29cb7ca6e5ffa744400cc880a0a3408e1c8b3

Authored by zhangxiaowen
1 parent 0b99cbcb

no message

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