-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathCodingSearchDisplayView.m
610 lines (569 loc) · 26.9 KB
/
CodingSearchDisplayView.m
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
//
// CodingSearchDisplayView.m
// Coding_iOS
//
// Created by Ease on 2016/12/15.
// Copyright © 2016年 Coding. All rights reserved.
//
#import "CodingSearchDisplayView.h"
#import "TopicHotkeyView.h"
#import "Coding_NetAPIManager.h"
#import "ODRefreshControl.h"
#import "SVPullToRefresh.h"
#import "XHRealTimeBlur.h"
#import "CSSearchModel.h"
#import "RKSwipeBetweenViewControllers.h"
#import "CSHotTopicView.h"
#import "CSMyTopicVC.h"
#import "UserInfoViewController.h"
#import "WebViewController.h"
#import "CSHotTopicPagesVC.h"
#import "CSTopicDetailVC.h"
#import "PublicSearchModel.h"
#import "Login.h"
#import "NSString+Attribute.h"
// cell--------------
#import "ProjectAboutMeListCell.h"
#import "FileSearchCell.h"
#import "TweetSearchCell.h"
#import "UserSearchCell.h"
#import "TaskSearchCell.h"
#import "TopicSearchCell.h"
#import "PRMRSearchCell.h"
// nav--------
#import "TweetDetailViewController.h"
#import "ConversationViewController.h"
@interface CodingSearchDisplayView ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *searchTableView;
@property (nonatomic, strong) UILabel *headerLabel;
@property (nonatomic, strong) NSMutableArray *dateSource;
@property (nonatomic, assign) BOOL isLoading;
@end
@implementation CodingSearchDisplayView
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
_searchTableView = ({
UITableView *tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
tableView.backgroundColor = [UIColor whiteColor];
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[tableView registerClass:[TweetSearchCell class] forCellReuseIdentifier:@"TweetSearchCell"];
[tableView registerClass:[ProjectAboutMeListCell class] forCellReuseIdentifier:@"ProjectAboutMeListCell"];
[tableView registerClass:[FileSearchCell class] forCellReuseIdentifier:@"FileSearchCell"];
[tableView registerClass:[UserSearchCell class] forCellReuseIdentifier:@"UserSearchCell"];
[tableView registerClass:[TaskSearchCell class] forCellReuseIdentifier:@"TaskSearchCell"];
[tableView registerClass:[TopicSearchCell class] forCellReuseIdentifier:@"TopicSearchCell"];
[tableView registerClass:[PRMRSearchCell class] forCellReuseIdentifier:@"PRMRSearchCell"];
tableView.dataSource = self;
tableView.delegate = self;
{
__weak typeof(self) weakSelf = self;
[tableView addInfiniteScrollingWithActionHandler:^{
[weakSelf loadMore];
}];
}
[self addSubview:tableView];
self.headerLabel = ({
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 2, kScreen_Width, 44)];
label.backgroundColor = [UIColor clearColor];
label.textColor = kColor999;
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont systemFontOfSize:12];
label;
});
UIView *headview = ({
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 44)];
v.backgroundColor = [UIColor whiteColor];
[v addSubview:self.headerLabel];
v;
});
tableView.tableHeaderView = headview;
tableView.estimatedRowHeight = 0;
tableView.estimatedSectionHeaderHeight = 0;
tableView.estimatedSectionFooterHeight = 0;
tableView;
});
}
return self;
}
- (void)setSearchPros:(PublicSearchModel *)searchPros{
_searchPros = searchPros;
self.dateSource = @[].mutableCopy;
switch (_curSearchType) {
case eSearchType_Project:
[self.dateSource addObjectsFromArray:_searchPros.projects.list];
break;
case eSearchType_Tweet:
[self.dateSource addObjectsFromArray:_searchPros.tweets.list];
break;
case eSearchType_Document:
[self.dateSource addObjectsFromArray:_searchPros.files.list];
break;
case eSearchType_User:
[self.dateSource addObjectsFromArray:_searchPros.friends.list];
break;
case eSearchType_Task:
[self.dateSource addObjectsFromArray:_searchPros.tasks.list];
break;
// case eSearchType_Topic:
// [self.dateSource addObjectsFromArray:_searchPros.project_topics.list];
// break;
case eSearchType_Merge:
[self.dateSource addObjectsFromArray:_searchPros.merge_requests.list];
break;
// case eSearchType_Pull:
// [self.dateSource addObjectsFromArray:_searchPros.pull_requests.list];
// break;
default:
break;
}
__weak typeof(self) weakSelf = self;
[_searchTableView configBlankPage:EaseBlankPageTypeProject_SEARCH hasData:[self noEmptyList] hasError:NO reloadButtonBlock:^(id sender) {
if (weakSelf.refreshAllBlock) {
weakSelf.refreshAllBlock();
}
}];
//空白页按钮事件
_searchTableView.blankPageView.clickButtonBlock=^(EaseBlankPageType curType) {
if (weakSelf.refreshAllBlock) {
weakSelf.refreshAllBlock();
}
};
[self refreshHeaderTitle];
[self.searchTableView reloadData];
[weakSelf.searchTableView.infiniteScrollingView stopAnimating];
_searchTableView.showsInfiniteScrolling = [self showTotalPage];
}
- (void)loadMore {
if(_isLoading){
[_searchTableView.infiniteScrollingView stopAnimating];
return;
}
//判断分类
int currentPage = 0;
int totalPage = 0;
switch (_curSearchType) {
case eSearchType_Project:
currentPage=[_searchPros.projects.page intValue];
totalPage=[_searchPros.projects.totalPage intValue];
break;
case eSearchType_Tweet:
currentPage=[_searchPros.tweets.page intValue];
totalPage=[_searchPros.tweets.totalPage intValue];
break;
case eSearchType_Document:
currentPage=[_searchPros.files.page intValue];
totalPage=[_searchPros.files.totalPage intValue];
break;
case eSearchType_User:
currentPage=[_searchPros.friends.page intValue];
totalPage=[_searchPros.friends.totalPage intValue];
break;
case eSearchType_Task:
currentPage=[_searchPros.tasks.page intValue];
totalPage=[_searchPros.tasks.totalPage intValue];
break;
// case eSearchType_Topic:
// currentPage=[_searchPros.project_topics.page intValue];
// totalPage=[_searchPros.project_topics.totalPage intValue];
// break;
case eSearchType_Merge:
currentPage=[_searchPros.merge_requests.page intValue];
totalPage=[_searchPros.merge_requests.totalPage intValue];
break;
// case eSearchType_Pull:
// currentPage=[_searchPros.pull_requests.page intValue];
// totalPage=[_searchPros.pull_requests.totalPage intValue];
// break;
default:
break;
}
if(currentPage >= totalPage)
{
[_searchTableView.infiniteScrollingView stopAnimating];
return;
}
[self requestDataWithPage:currentPage + 1];
}
- (void)requestDataWithPage:(NSInteger)page {
_isLoading = YES;
__weak typeof(self) weakSelf = self;
if (_curSearchType==eSearchType_Tweet) {
[[Coding_NetAPIManager sharedManager] requestWithSearchString:_searchBarText typeStr:@"tweet" andPage:page andBlock:^(id data, NSError *error) {
if(data) {
NSDictionary *dataDic = (NSDictionary *)data;
NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"Tweet"];
[weakSelf.searchPros.tweets.list addObjectsFromArray:resultA];
//更新page
weakSelf.searchPros.tweets.page = dataDic[@"page"] ;
weakSelf.searchPros.tweets.totalPage = dataDic[@"totalPage"] ;
[weakSelf.dateSource addObjectsFromArray:resultA];
[weakSelf.searchTableView reloadData];
[weakSelf.searchTableView.infiniteScrollingView stopAnimating];
weakSelf.searchTableView.showsInfiniteScrolling = [weakSelf showTotalPage];
}
weakSelf.isLoading = NO;
}];
}else if(_curSearchType==eSearchType_Project){
[[Coding_NetAPIManager sharedManager] requestWithSearchString:_searchBarText typeStr:@"project" andPage:page andBlock:^(id data, NSError *error) {
if(data) {
NSDictionary *dataDic = (NSDictionary *)data;
NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"Project"];
[weakSelf.searchPros.projects.list addObjectsFromArray:resultA];
//更新page
weakSelf.searchPros.projects.page = dataDic[@"page"] ;
weakSelf.searchPros.projects.totalPage = dataDic[@"totalPage"] ;
[weakSelf.dateSource addObjectsFromArray:resultA];
[weakSelf.searchTableView reloadData];
[weakSelf.searchTableView.infiniteScrollingView stopAnimating];
weakSelf.searchTableView.showsInfiniteScrolling = [weakSelf showTotalPage];
}
weakSelf.isLoading = NO;
}];
}else if(_curSearchType==eSearchType_Document){
[[Coding_NetAPIManager sharedManager] requestWithSearchString:_searchBarText typeStr:@"file" andPage:page andBlock:^(id data, NSError *error) {
if(data) {
NSDictionary *dataDic = (NSDictionary *)data;
NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"ProjectFile"];
[weakSelf.searchPros.files.list addObjectsFromArray:resultA];
//更新page
weakSelf.searchPros.files.page = dataDic[@"page"] ;
weakSelf.searchPros.files.totalPage = dataDic[@"totalPage"] ;
[weakSelf.dateSource addObjectsFromArray:resultA];
[weakSelf.searchTableView reloadData];
[weakSelf.searchTableView.infiniteScrollingView stopAnimating];
weakSelf.searchTableView.showsInfiniteScrolling = [weakSelf showTotalPage];
}
weakSelf.isLoading = NO;
}];
}else if(_curSearchType==eSearchType_Merge){
[[Coding_NetAPIManager sharedManager] requestWithSearchString:_searchBarText typeStr:@"mr" andPage:page andBlock:^(id data, NSError *error) {
if(data) {
NSDictionary *dataDic = (NSDictionary *)data;
NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"MRPR"];
[weakSelf.searchPros.merge_requests.list addObjectsFromArray:resultA];
//更新page
weakSelf.searchPros.merge_requests.page = dataDic[@"page"] ;
weakSelf.searchPros.merge_requests.totalPage = dataDic[@"totalPage"] ;
[weakSelf.dateSource addObjectsFromArray:resultA];
[weakSelf.searchTableView reloadData];
[weakSelf.searchTableView.infiniteScrollingView stopAnimating];
weakSelf.searchTableView.showsInfiniteScrolling = [weakSelf showTotalPage];
}
weakSelf.isLoading = NO;
}];
// }else if(_curSearchType==eSearchType_Pull){
// [[Coding_NetAPIManager sharedManager] requestWithSearchString:_searchBarText typeStr:@"pr" andPage:page andBlock:^(id data, NSError *error) {
// if(data) {
// NSDictionary *dataDic = (NSDictionary *)data;
// NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"MRPR"];
// [weakSelf.searchPros.pull_requests.list addObjectsFromArray:resultA];
// //更新page
// weakSelf.searchPros.pull_requests.page = dataDic[@"page"] ;
// weakSelf.searchPros.pull_requests.totalPage = dataDic[@"totalPage"] ;
// [weakSelf.dateSource addObjectsFromArray:resultA];
// [weakSelf.searchTableView reloadData];
// [weakSelf.searchTableView.infiniteScrollingView stopAnimating];
// weakSelf.searchTableView.showsInfiniteScrolling = [weakSelf showTotalPage];
// }
// weakSelf.isLoading = NO;
// }];
}else if(_curSearchType==eSearchType_Task){
[[Coding_NetAPIManager sharedManager] requestWithSearchString:_searchBarText typeStr:@"task" andPage:page andBlock:^(id data, NSError *error) {
if(data) {
NSDictionary *dataDic = (NSDictionary *)data;
NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"Task"];
//task 处理 description 关键字
NSArray *resultTask =dataDic[@"list"];
for (int i=0;i<[resultA count];i++) {
Task *curTask=[resultA objectAtIndex:i];
if ([resultTask count]>i) {
curTask.descript= [[[resultTask objectAtIndex:i] objectForKey:@"description"] firstObject];
}
}
[weakSelf.searchPros.tasks.list addObjectsFromArray:resultA];
//更新page
weakSelf.searchPros.tasks.page = dataDic[@"page"] ;
weakSelf.searchPros.tasks.totalPage = dataDic[@"totalPage"] ;
[weakSelf.dateSource addObjectsFromArray:resultA];
[weakSelf.searchTableView reloadData];
[weakSelf.searchTableView.infiniteScrollingView stopAnimating];
weakSelf.searchTableView.showsInfiniteScrolling = [weakSelf showTotalPage];
}
weakSelf.isLoading = NO;
}];
}else if(_curSearchType==eSearchType_User){
[[Coding_NetAPIManager sharedManager] requestWithSearchString:_searchBarText typeStr:@"user" andPage:page andBlock:^(id data, NSError *error) {
if(data) {
NSDictionary *dataDic = (NSDictionary *)data;
NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"User"];
[weakSelf.searchPros.friends.list addObjectsFromArray:resultA];
//更新page
weakSelf.searchPros.friends.page = dataDic[@"page"] ;
weakSelf.searchPros.friends.totalPage = dataDic[@"totalPage"] ;
[weakSelf.dateSource addObjectsFromArray:resultA];
[weakSelf.searchTableView reloadData];
[weakSelf.searchTableView.infiniteScrollingView stopAnimating];
weakSelf.searchTableView.showsInfiniteScrolling = [weakSelf showTotalPage];
}
weakSelf.isLoading = NO;
}];
// }else if(_curSearchType==eSearchType_Topic){
// [[Coding_NetAPIManager sharedManager] requestWithSearchString:_searchBarText typeStr:@"topic" andPage:page andBlock:^(id data, NSError *error) {
// if(data) {
// NSDictionary *dataDic = (NSDictionary *)data;
// NSArray *resultA = [NSObject arrayFromJSON:dataDic[@"list"] ofObjects:@"ProjectTopic"];
//
// //topic 处理 content 关键字
// NSArray *resultTopic =dataDic[@"list"];
// for (int i=0;i<[resultA count];i++) {
// ProjectTopic *curTopic=[resultA objectAtIndex:i];
// if ([resultTopic count]>i) {
// curTopic.contentStr= [[[resultTopic objectAtIndex:i] objectForKey:@"content"] firstObject];
// }
// }
//
// [weakSelf.searchPros.project_topics.list addObjectsFromArray:resultA];
// //更新page
// weakSelf.searchPros.project_topics.page = dataDic[@"page"] ;
// weakSelf.searchPros.project_topics.totalPage = dataDic[@"totalPage"] ;
// [weakSelf.dateSource addObjectsFromArray:resultA];
// [weakSelf.searchTableView reloadData];
// [weakSelf.searchTableView.infiniteScrollingView stopAnimating];
// weakSelf.searchTableView.showsInfiniteScrolling = [weakSelf showTotalPage];
// }
// weakSelf.isLoading = NO;
// }];
}else{
[self.searchTableView.infiniteScrollingView stopAnimating];
self.searchTableView.showsInfiniteScrolling = NO;
self.isLoading=NO;
}
}
//更新header数量和类型统计
- (void)refreshHeaderTitle{
NSString *titleStr;
switch (_curSearchType) {
case eSearchType_Project:
if ([_searchPros.projects.totalRow longValue]==0) {
titleStr=nil;
}else{
titleStr=[NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的项目", [_searchPros.projects.totalRow longValue],_searchBarText];
}
break;
case eSearchType_Tweet:
if ([_searchPros.tweets.totalRow longValue]==0) {
titleStr=nil;
}else{
titleStr=[NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的冒泡", [_searchPros.tweets.totalRow longValue],_searchBarText];
}
break;
case eSearchType_Document:
if ([_searchPros.files.totalRow longValue]==0) {
titleStr=nil;
}else{
titleStr=[NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的文档", [_searchPros.files.totalRow longValue],_searchBarText];
}
break;
case eSearchType_User:
if ([_searchPros.friends.totalRow longValue]==0) {
titleStr=nil;
}else{
titleStr=[NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的用户", [_searchPros.friends.totalRow longValue],_searchBarText];
}
break;
case eSearchType_Task:
if ([_searchPros.tasks.totalRow longValue]==0) {
titleStr=nil;
}else{
titleStr=[NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的任务", [_searchPros.tasks.totalRow longValue],_searchBarText];
}
break;
// case eSearchType_Topic:
// if ([_searchPros.project_topics.totalRow longValue]==0) {
// titleStr=nil;
// }else{
// titleStr=[NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的讨论", [_searchPros.project_topics.totalRow longValue],_searchBarText];
// }
// break;
case eSearchType_Merge:
if ([_searchPros.merge_requests.totalRow longValue]==0) {
titleStr=nil;
}else{
titleStr=[NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的合并请求", [_searchPros.merge_requests.totalRow longValue],_searchBarText];
}
break;
// case eSearchType_Pull:
// if ([_searchPros.pull_requests.totalRow longValue]==0) {
// titleStr=nil;
// }else{
// titleStr=[NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的 Pull 请求", [_searchPros.pull_requests.totalRow longValue],_searchBarText];
// }
// break;
default:
break;
}
self.headerLabel.text=titleStr;
}
//是否显示加载更多
-(BOOL)showTotalPage{
switch (_curSearchType) {
case eSearchType_Project:
return _searchPros.projects.page<_searchPros.projects.totalPage;
break;
case eSearchType_Tweet:
return _searchPros.tweets.page<_searchPros.tweets.totalPage;
break;
case eSearchType_Document:
return _searchPros.files.page<_searchPros.files.totalPage;
break;
case eSearchType_User:
return _searchPros.friends.page<_searchPros.friends.totalPage;
break;
case eSearchType_Task:
return _searchPros.tasks.page<_searchPros.tasks.totalPage;
break;
// case eSearchType_Topic:
// return _searchPros.project_topics.page<_searchPros.project_topics.totalPage;
// break;
case eSearchType_Merge:
return _searchPros.merge_requests.page<_searchPros.merge_requests.totalPage;
break;
// case eSearchType_Pull:
// return _searchPros.pull_requests.page<_searchPros.pull_requests.totalPage;
// break;
default:
return NO;
break;
}
}
//判断是否空
-(BOOL)noEmptyList{
switch (_curSearchType) {
case eSearchType_Project:
return [_searchPros.projects.list count];
break;
case eSearchType_Tweet:
return [_searchPros.tweets.list count];
break;
case eSearchType_Document:
return [_searchPros.files.list count];
break;
case eSearchType_User:
return [_searchPros.friends.list count];
break;
case eSearchType_Task:
return [_searchPros.tasks.list count];
break;
// case eSearchType_Topic:
// return [_searchPros.project_topics.list count];
// break;
case eSearchType_Merge:
return [_searchPros.merge_requests.list count];
break;
// case eSearchType_Pull:
// return [_searchPros.pull_requests.list count];
// break;
default:
return TRUE;
break;
}
}
#pragma mark - UITableViewDelegate & UITableViewDataSource Support
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_dateSource count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (_curSearchType==eSearchType_Tweet) {
TweetSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TweetSearchCell" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Tweet *tweet = _dateSource[indexPath.row];
cell.tweet = tweet;
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
return cell;
}else if(_curSearchType==eSearchType_Project){
ProjectAboutMeListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ProjectAboutMeListCell" forIndexPath:indexPath];
cell.openKeywords=TRUE;
Project *project=_dateSource[indexPath.row];
[cell setProject:project hasSWButtons:NO hasBadgeTip:YES hasIndicator:NO];
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
return cell;
}else if(_curSearchType==eSearchType_Document){
FileSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FileSearchCell" forIndexPath:indexPath];
ProjectFile *file =_dateSource[indexPath.row];
cell.file = file;
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
return cell;
}else if(_curSearchType==eSearchType_User){
UserSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UserSearchCell" forIndexPath:indexPath];
User *curUser = _dateSource[indexPath.row];
cell.curUser = curUser;
__weak typeof(self) weakSelf = self;
cell.rightBtnClickedBlock=^(User *curUser) {
if (weakSelf.goToConversationBlock) {
weakSelf.goToConversationBlock(curUser);
}
};
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
return cell;
}else if(_curSearchType==eSearchType_Task){
TaskSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TaskSearchCell" forIndexPath:indexPath];
Task *task =_dateSource[indexPath.row];
cell.task=task;
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
return cell;
// }else if(_curSearchType==eSearchType_Topic){
// TopicSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TopicSearchCell" forIndexPath:indexPath];
// ProjectTopic *topic =_dateSource[indexPath.row];
// cell.curTopic = topic;
// [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
// return cell;
}else if(_curSearchType==eSearchType_Merge){
PRMRSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PRMRSearchCell" forIndexPath:indexPath];
MRPR *curMRPR =_dateSource[indexPath.row];
cell.curMRPR = curMRPR;
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
return cell;
// }else if(_curSearchType==eSearchType_Pull){
// PRMRSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PRMRSearchCell" forIndexPath:indexPath];
// MRPR *curMRPR =_dateSource[indexPath.row];
// cell.curMRPR = curMRPR;
// [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
// return cell;
}else{
return [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (_curSearchType==eSearchType_Tweet) {
Tweet *tweet = _dateSource[indexPath.row];
return[TweetSearchCell cellHeightWithObj:tweet];
}else if(_curSearchType==eSearchType_Project){
return kProjectAboutMeListCellHeight;
}else if(_curSearchType==eSearchType_Document){
return kFileSearchCellHeight;
}else if(_curSearchType==eSearchType_User){
return kUserSearchCellHeight;
}else if(_curSearchType==eSearchType_Task){
Task *task = _dateSource[indexPath.row];
return [TaskSearchCell cellHeightWithObj:task];
// }else if(_curSearchType==eSearchType_Topic){
// ProjectTopic *topic = _dateSource[indexPath.row];
// return [TopicSearchCell cellHeightWithObj:topic];
// }else if (_curSearchType==eSearchType_Pull){
// MRPR *mrpr = _dateSource[indexPath.row];
// return [PRMRSearchCell cellHeightWithObj:mrpr];
}else if (_curSearchType==eSearchType_Merge){
MRPR *mrpr = _dateSource[indexPath.row];
return [PRMRSearchCell cellHeightWithObj:mrpr];
}else{
return 100;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
if (_cellClickedBlock) {
_cellClickedBlock(_dateSource[indexPath.row], _curSearchType);
}
}
@end