GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Coding-iOS/Coding_iOS/Controllers/Topic/CSTopiclistView.m at master · Solertis/Coding-iOS Expand file tree/ Copy pathCSTopiclistView.mMore file actions 229 lines (186 loc) · 7.19 KB / Copy pathCSTopiclistView.mFile metadata and controls229 lines (186 loc) · 7.19 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 // // CSTopiclistView.m // Coding_iOS // // Created by pan Shiyu on 15/7/24. // Copyright (c) 2015年 Coding. All rights reserved. // #import "CSTopiclistView.h" #import "ProjectListTaCell.h" #import "ODRefreshControl.h" #import "Coding_NetAPIManager.h" #import "SVPullToRefresh.h" #import "Login.h" #import "CSHotTopicView.h" #define kCellIdentifier_TopicList @"TopicListCell" @interface CSTopiclistView()<SWTableViewCellDelegate> @property (nonatomic, strong) NSDictionary *myTopic; @property (nonatomic , copy) TopicListViewBlock block; @property (nonatomic, strong) UITableView *myTableView; @property (nonatomic, strong) ODRefreshControl *myRefreshControl; @property (strong, nonatomic) NSMutableArray *dataList; //根据不同的type,走不同而数据更新逻辑,外界不传值进来 @property (nonatomic,assign)CSMyTopicsType type; @property (nonatomic, strong) NSString *globalKey; @property (nonatomic,assign)BOOL isLodding; @property (nonatomic, assign) BOOL hasMore; @property (nonatomic, assign) NSInteger curPage; @end @implementation CSTopiclistView - (id)initWithFrame:(CGRect)frame globalKey:(NSString *)key type:(CSMyTopicsType )type block:(TopicListViewBlock)block { self = [super initWithFrame:frame]; if (self) { // Initialization code _dataList = [[NSMutableArray alloc] init]; _globalKey = key == nil ? [[Login curLoginUser].global_key copy] : [key copy]; _type = type; _block = block; _myTableView = ({ UITableView *tableView = [[UITableView alloc] init]; tableView.backgroundColor = [UIColor clearColor]; tableView.delegate = self; tableView.dataSource = self; [tableView registerClass:[CSTopicCell class] forCellReuseIdentifier:kCellIdentifier_TopicCell]; tableView.separatorStyle = UITableViewCellSeparatorStyleNone; { __weak typeof(self) weakSelf = self; [tableView addInfiniteScrollingWithActionHandler:^{ [weakSelf loadMore]; }]; } [self addSubview:tableView]; [tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self); }]; // if (tabBarHeight != 0 && projects.type < ProjectsTypeTaProject) { // UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, tabBarHeight, 0); // tableView.contentInset = insets; // tableView.scrollIndicatorInsets = insets; // } tableView.estimatedRowHeight = 0; tableView.estimatedSectionHeaderHeight = 0; tableView.estimatedSectionFooterHeight = 0; tableView; }); // _myRefreshControl = [[ODRefreshControl alloc] initInScrollView:self.myTableView]; // [_myRefreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged]; self.hasMore = YES; self.curPage = 1; if (_myTopic.count > 0) { [_myTableView reloadData]; }else{ [self sendRequest]; } } return self; } - (void)setTopics:(id )topics{ self.myTopic = topics; [self setupDataList]; } - (void)setupDataList{ // if (!_dataList) { // _dataList = [[NSMutableArray alloc] initWithCapacity:2]; // } // [_dataList removeAllObjects]; // if (_myProjects.type < ProjectsTypeToChoose) { // NSArray *pinList = _myProjects.pinList, *noPinList = _myProjects.noPinList; // if (pinList.count > 0) { // [_dataList addObject:@{kTitleKey : @"常用项目", // kValueKey : pinList}]; // } // if (noPinList.count > 0) { // [_dataList addObject:@{kTitleKey : @"一般项目", // kValueKey : noPinList}]; // } // }else{ // NSArray *list = [self updateFilteredContentForSearchString:self.mySearchBar.text]; // if (list.count > 0) { // [_dataList addObject:@{kTitleKey : @"一般项目", // kValueKey : list}]; // } // } } - (void)refresh{ if (self.isLodding) { return; } [self sendRequest]; } - (void)loadMore { if(self.isLodding) { return; } ++self.curPage; [self sendRequest]; } - (void)sendRequest{ if (_dataList.count <= 0) { [self beginLoading]; } __weak typeof(self) weakSelf = self; if (_type == CSMyTopicsTypeWatched) { [[Coding_NetAPIManager sharedManager] request_WatchedTopicsWithUserGK:weakSelf.globalKey page:weakSelf.curPage block:^(id data, BOOL hasMoreData, NSError *error) { weakSelf.hasMore = hasMoreData; [weakSelf doAfterGotResultWithData:data error:error]; }]; }else{ [[Coding_NetAPIManager sharedManager] request_JoinedTopicsWithUserGK:weakSelf.globalKey page:weakSelf.curPage block:^(id data, BOOL hasMoreData, NSError *error) { weakSelf.hasMore = hasMoreData; [weakSelf doAfterGotResultWithData:data error:error]; }]; } } - (void)doAfterGotResultWithData:(id) data error:(NSError*)error { [self.myTableView.infiniteScrollingView stopAnimating]; [self.myRefreshControl endRefreshing]; [self endLoading]; if (data) { [_dataList addObjectsFromArray:[data[@"list"] copy]]; self.myTableView.showsInfiniteScrolling = self.hasMore; [self.myTableView reloadData]; } EaseBlankPageType blankPageType; if (_type == CSMyTopicsTypeWatched) { if (_isMe) { blankPageType = EaseBlankPageTypeMyWatchedTopic; }else{ blankPageType = EaseBlankPageTypeOthersWatchedTopic; } }else{ if(_isMe){ blankPageType = EaseBlankPageTypeMyJoinedTopic; }else{ blankPageType = EaseBlankPageTypeOthersJoinedTopic; } } [self configBlankPage:blankPageType hasData:(self.dataList.count > 0) hasError:(error != nil) reloadButtonBlock:^(id sender) { [self refresh]; }]; } - (void)refreshToQueryData { } #pragma mark Table M - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return _dataList.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSDictionary *topic = _dataList[indexPath.row]; CSTopicCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_TopicCell forIndexPath:indexPath]; [cell updateDisplayByTopic:topic]; cell.delegate = self; [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ NSDictionary *topic = _dataList[indexPath.row]; return [CSTopicCell cellHeightWithData:topic]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; NSDictionary *topic = _dataList[indexPath.row]; if (_block) { _block(topic); } } @end |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |