1717#import " RKSwipeBetweenViewControllers.h"
1818#import " CSHotTopicView.h"
1919#import " CSMyTopicVC.h"
20- #import " CSSearchCell .h"
20+ #import " TweetSearchCell .h"
2121#import " UserInfoViewController.h"
2222#import " WebViewController.h"
2323#import " TweetDetailViewController.h"
@@ -44,7 +44,7 @@ @interface AllSearchDisplayVC () <UISearchBarDelegate, UITableViewDelegate, UITa
4444@property (nonatomic , assign ) NSInteger totalCount;
4545@property (nonatomic , assign ) BOOL isLoading;
4646@property (nonatomic , strong ) UILabel *headerLabel;
47-
47+ @property ( nonatomic , strong ) PublicSearchModel *searchPros;
4848@property (nonatomic , strong ) UIScrollView *searchHistoryView;
4949
5050- (void )initSubViewsInContentView ;
@@ -210,7 +210,7 @@ - (void)initSearchResultsTableView {
210210 UITableView *tableView = [[UITableView alloc ] initWithFrame: _contentView.frame style: UITableViewStylePlain];
211211 tableView.backgroundColor = [UIColor whiteColor ];
212212 tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
213- [tableView registerClass: [CSSearchCell class ] forCellReuseIdentifier: @" CSSearchCell " ];
213+ [tableView registerClass: [TweetSearchCell class ] forCellReuseIdentifier: @" TweetSearchCell " ];
214214 [tableView registerClass: [ProjectAboutMeListCell class ] forCellReuseIdentifier: @" ProjectAboutMeListCell" ];
215215 tableView.dataSource = self;
216216 tableView.delegate = self;
@@ -383,6 +383,21 @@ - (void)loadMore {
383383 [self requestDataWithPage: _currentPage + 1 ];
384384}
385385
386+ -(void )reloadDisplayData {
387+ [self .dateSource removeAllObjects ];
388+ switch (_curSearchType) {
389+ case eSearchType_Project:
390+ [self .dateSource addObjectsFromArray: _searchPros.projects.list];
391+ break ;
392+ case eSearchType_Tweet:
393+ [self .dateSource addObjectsFromArray: _searchPros.tweets.list];
394+ break ;
395+ default :
396+ break ;
397+ }
398+ [self .searchTableView reloadData ];
399+ }
400+
386401- (void )requestDataWithPage : (NSInteger )page {
387402
388403 if (page < 1 )
@@ -394,43 +409,56 @@ - (void)requestDataWithPage:(NSInteger)page {
394409 _isLoading = YES ;
395410
396411 __weak typeof (self) weakSelf = self;
397- if (_curSearchType==eSearchType_Tweet) {
398- [[Coding_NetAPIManager sharedManager ] requestWithSearchString: self .searchBar.text typeStr: @" tweet" andPage: page andBlock: ^(id data, NSError *error) {
399-
400- if (data) {
401- NSDictionary *dataDic = (NSDictionary *)data;
402- weakSelf.currentPage = [[dataDic valueForKey: @" page" ] intValue ];
403- weakSelf.totalPage = [[dataDic valueForKey: @" totalPage" ] intValue ];
404- weakSelf.totalCount = [[dataDic valueForKey: @" totalRow" ] intValue ];
405- NSArray *resultA = [NSObject arrayFromJSON: [dataDic objectForKey: @" list" ] ofObjects: @" Tweet" ];
406- [weakSelf.dateSource addObjectsFromArray: resultA];
407- [weakSelf.searchTableView reloadData ];
408- [weakSelf.searchTableView.infiniteScrollingView stopAnimating ];
409- weakSelf.searchTableView .showsInfiniteScrolling = weakSelf.currentPage >= weakSelf.totalPage ? NO : YES ;
410- }
411-
412- weakSelf.isLoading = NO ;
413- weakSelf.headerLabel .text = [NSString stringWithFormat: @" 共搜索到 %ld 个与\" %@ \" 相关的冒泡" , (long )weakSelf.totalCount, weakSelf.searchBar.text, nil ];
414- }];
415- }else if (_curSearchType==eSearchType_Project){
412+ // if (_curSearchType==eSearchType_Tweet) {
413+ // [[Coding_NetAPIManager sharedManager] requestWithSearchString:self.searchBar.text typeStr:@"tweet" andPage:page andBlock:^(id data, NSError *error) {
414+ //
415+ // if(data) {
416+ // NSDictionary *dataDic = (NSDictionary *)data;
417+ // weakSelf.currentPage = [[dataDic valueForKey:@"page"] intValue];
418+ // weakSelf.totalPage = [[dataDic valueForKey:@"totalPage"] intValue];
419+ // weakSelf.totalCount = [[dataDic valueForKey:@"totalRow"] intValue];
420+ // NSArray *resultA = [NSObject arrayFromJSON:[dataDic objectForKey:@"list"] ofObjects:@"Tweet"];
421+ // [weakSelf.dateSource addObjectsFromArray:resultA];
422+ // [weakSelf.searchTableView reloadData];
423+ // [weakSelf.searchTableView.infiniteScrollingView stopAnimating];
424+ // weakSelf.searchTableView.showsInfiniteScrolling = weakSelf.currentPage >= weakSelf.totalPage ? NO : YES;
425+ // }
426+ //
427+ // weakSelf.isLoading = NO;
428+ // weakSelf.headerLabel.text = [NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的冒泡", (long)weakSelf.totalCount, weakSelf.searchBar.text, nil];
429+ // }];
430+ // }else if(_curSearchType==eSearchType_Project){
431+ // [[Coding_NetAPIManager sharedManager] requestWithSearchString:self.searchBar.text typeStr:@"all" andPage:page andBlock:^(id data, NSError *error) {
432+ // if(data) {
433+ // PublicSearchModel *pros = [NSObject objectOfClass:@"PublicSearchModel" fromJSON:data];
434+ // [weakSelf.dateSource addObjectsFromArray:pros.projects.list];
435+ // [weakSelf.searchTableView reloadData];
436+ // [weakSelf.searchTableView.infiniteScrollingView stopAnimating];
437+ // }
438+ // weakSelf.isLoading = NO;
439+ // weakSelf.headerLabel.text = [NSString stringWithFormat:@"共搜索到 %ld 个与\"%@\"相关的项目", (long)weakSelf.totalCount, weakSelf.searchBar.text, nil];
440+ // }];
441+ // }
442+
416443 [[Coding_NetAPIManager sharedManager ] requestWithSearchString: self .searchBar.text typeStr: @" all" andPage: page andBlock: ^(id data, NSError *error) {
417444 if (data) {
418- PublicSearchModel *pros = [NSObject objectOfClass: @" PublicSearchModel" fromJSON: data];
419-
420- // NSArray *resultA = [NSObject arrayFromJSON:[dataDic objectForKey:@"list"] ofObjects:@"Tweet"];
421- //
422- [weakSelf.dateSource addObjectsFromArray: pros.projects.list];
445+ _searchPros = [NSObject objectOfClass: @" PublicSearchModel" fromJSON: data];
446+ switch (_curSearchType) {
447+ case eSearchType_Project:
448+ [weakSelf.dateSource addObjectsFromArray: _searchPros.projects.list];
449+ break ;
450+ case eSearchType_Tweet:
451+ [weakSelf.dateSource addObjectsFromArray: _searchPros.tweets.list];
452+ break ;
453+ default :
454+ break ;
455+ }
423456 [weakSelf.searchTableView reloadData ];
424457 [weakSelf.searchTableView.infiniteScrollingView stopAnimating ];
425-
426- // NSArray *resultA = [NSObject arrayFromJSON:[dataDic objectForKey:@"list"] ofObjects:@"Tweet"];
427- // [weakSelf.dateSource addObjectsFromArray:resultA];
428- // [weakSelf.searchTableView reloadData];
429- // [weakSelf.searchTableView.infiniteScrollingView stopAnimating];
430- // weakSelf.searchTableView.showsInfiniteScrolling = weakSelf.currentPage >= weakSelf.totalPage ? NO : YES;
431458 }
459+ weakSelf.isLoading = NO ;
460+ weakSelf.headerLabel .text = [NSString stringWithFormat: @" 共搜索到 %ld 个与\" %@ \" 相关的项目" , (long )weakSelf.totalCount, weakSelf.searchBar.text, nil ];
432461 }];
433- }
434462}
435463
436464- (void )analyseLinkStr : (NSString *)linkStr {
@@ -448,7 +476,6 @@ - (void)analyseLinkStr:(NSString *)linkStr{
448476}
449477
450478
451-
452479#pragma mark -
453480#pragma mark UISearchBarDelegate Support
454481
@@ -473,7 +500,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
473500- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
474501
475502 if (_curSearchType==eSearchType_Tweet) {
476- CSSearchCell *cell = [tableView dequeueReusableCellWithIdentifier: @" CSSearchCell " forIndexPath: indexPath];
503+ TweetSearchCell *cell = [tableView dequeueReusableCellWithIdentifier: @" TweetSearchCell " forIndexPath: indexPath];
477504 cell.selectionStyle = UITableViewCellSelectionStyleNone;
478505 Tweet *tweet = _dateSource[indexPath.row];
479506 cell.tweet = tweet;
@@ -489,14 +516,15 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
489516 [weakSelf analyseLinkStr: curItem.href];
490517 };
491518
492- [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 0 ];
519+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
493520 return cell;
494521 }else if (_curSearchType==eSearchType_Project){
495522 ProjectAboutMeListCell *cell = [tableView dequeueReusableCellWithIdentifier: @" ProjectAboutMeListCell" forIndexPath: indexPath];
523+ cell.openKeywords =TRUE ;
496524 Project *project=_dateSource[indexPath.row];
497525 [cell setProject: project hasSWButtons: NO hasBadgeTip: YES hasIndicator: NO ];
498526 cell.delegate = self;
499- // [tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpaceAndSectionLine :kPaddingLeftWidth];
527+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace :kPaddingLeftWidth ];
500528 return cell;
501529 }
502530 else {
@@ -507,7 +535,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
507535- (CGFloat)tableView : (UITableView *)tableView heightForRowAtIndexPath : (NSIndexPath *)indexPath {
508536 if (_curSearchType==eSearchType_Tweet) {
509537 Tweet *tweet = _dateSource[indexPath.row];
510- return [CSSearchCell cellHeightWithObj: tweet];
538+ return [TweetSearchCell cellHeightWithObj: tweet];
511539 }else if (_curSearchType==eSearchType_Project){
512540 return kProjectAboutMeListCellHeight ;
513541 }
0 commit comments