77//
88
99#import " AllSearchDisplayVC.h"
10-
1110#import " TopicHotkeyView.h"
1211#import " Coding_NetAPIManager.h"
1312#import " ODRefreshControl.h"
1918#import " CSMyTopicVC.h"
2019#import " UserInfoViewController.h"
2120#import " WebViewController.h"
22-
2321#import " CSHotTopicPagesVC.h"
2422#import " CSTopicDetailVC.h"
2523#import " PublicSearchModel.h"
3331#import " UserSearchCell.h"
3432#import " TaskSearchCell.h"
3533#import " TopicSearchCell.h"
34+ #import " PRMRSearchCell.h"
3635
3736// nav--------
3837#import " TweetDetailViewController.h"
@@ -158,7 +157,7 @@ - (void)initSearchResultsTableView {
158157 [tableView registerClass: [UserSearchCell class ] forCellReuseIdentifier: @" UserSearchCell" ];
159158 [tableView registerClass: [TaskSearchCell class ] forCellReuseIdentifier: @" TaskSearchCell" ];
160159 [tableView registerClass: [TopicSearchCell class ] forCellReuseIdentifier: @" TopicSearchCell" ];
161-
160+ [tableView registerClass: [PRMRSearchCell class ] forCellReuseIdentifier: @" PRMRSearchCell " ];
162161
163162 tableView.dataSource = self;
164163 tableView.delegate = self;
@@ -343,6 +342,11 @@ - (void)goToTopic:(ProjectTopic*)curTopic{
343342 [self .parentVC.navigationController pushViewController: vc animated: YES ];
344343}
345344
345+ - (void )goToMRDetail : (MRPR *)curMR {
346+ UIViewController *vc = [BaseViewController analyseVCFromLinkStr: curMR.path];
347+ [self .parentVC.navigationController pushViewController: vc animated: YES ];
348+ }
349+
346350
347351#pragma mark -
348352#pragma mark Search Data Request
@@ -387,6 +391,12 @@ -(void)reloadDisplayData{
387391 case eSearchType_Topic:
388392 [self .dateSource addObjectsFromArray: _searchPros.project_topics.list];
389393 break ;
394+ case eSearchType_Merge:
395+ [self .dateSource addObjectsFromArray: _searchPros.merge_requests.list];
396+ break ;
397+ case eSearchType_Pull:
398+ [self .dateSource addObjectsFromArray: _searchPros.pull_requests.list];
399+ break ;
390400 default :
391401 break ;
392402 }
@@ -417,6 +427,12 @@ - (void)refreshHeaderTitle{
417427 case eSearchType_Topic:
418428 titleStr=[NSString stringWithFormat: @" 共搜索到 %ld 个与\" %@ \" 相关的讨论" , [_searchPros.project_topics.totalRow longValue ],self .searchBar.text];
419429 break ;
430+ case eSearchType_Merge:
431+ titleStr=[NSString stringWithFormat: @" 共搜索到 %ld 个与\" %@ \" 相关的合并请求" , [_searchPros.merge_requests.totalRow longValue ],self .searchBar.text];
432+ break ;
433+ case eSearchType_Pull:
434+ titleStr=[NSString stringWithFormat: @" 共搜索到 %ld 个与\" %@ \" 相关的pull请求" , [_searchPros.pull_requests.totalRow longValue ],self .searchBar.text];
435+ break ;
420436 default :
421437 break ;
422438 }
@@ -476,7 +492,6 @@ - (void)requestDataWithPage:(NSInteger)page {
476492 curTopic.content = [[[resultA objectAtIndex: i] objectForKey: @" content" ] firstObject ];
477493 }
478494 }
479-
480495 switch (_curSearchType) {
481496 case eSearchType_Project:
482497 [weakSelf.dateSource addObjectsFromArray: _searchPros.projects.list];
@@ -496,6 +511,12 @@ - (void)requestDataWithPage:(NSInteger)page {
496511 case eSearchType_Topic:
497512 [weakSelf.dateSource addObjectsFromArray: _searchPros.project_topics.list];
498513 break ;
514+ case eSearchType_Merge:
515+ [weakSelf.dateSource addObjectsFromArray: _searchPros.merge_requests.list];
516+ break ;
517+ case eSearchType_Pull:
518+ [weakSelf.dateSource addObjectsFromArray: _searchPros.pull_requests.list];
519+ break ;
499520 default :
500521 break ;
501522 }
@@ -589,6 +610,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
589610 cell.curTopic = topic;
590611 [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
591612 return cell;
613+ }else if (_curSearchType==eSearchType_Merge){
614+ PRMRSearchCell *cell = [tableView dequeueReusableCellWithIdentifier: @" PRMRSearchCell" forIndexPath: indexPath];
615+ MRPR *curMRPR =_dateSource[indexPath.row];
616+ cell.curMRPR = curMRPR;
617+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
618+ return cell;
619+ }else if (_curSearchType==eSearchType_Pull){
620+ PRMRSearchCell *cell = [tableView dequeueReusableCellWithIdentifier: @" PRMRSearchCell" forIndexPath: indexPath];
621+ MRPR *curMRPR =_dateSource[indexPath.row];
622+ cell.curMRPR = curMRPR;
623+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
624+ return cell;
592625 }else {
593626 return nil ;
594627 }
@@ -608,14 +641,18 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
608641 return kTaskSearchCellHeight ;
609642 }else if (_curSearchType==eSearchType_Topic){
610643 return kTopicSearchCellHeight ;
644+ }else if (_currentPage==eSearchType_Pull){
645+ return [PRMRSearchCell cellHeight ];
646+ }else if (_currentPage==eSearchType_Merge){
647+ return [PRMRSearchCell cellHeight ];
611648 }else {
612649 return 100 ;
613650 }
614651}
615652
616653- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
617654 [tableView deselectRowAtIndexPath: indexPath animated: NO ];
618- if (_curSearchType==eSearchType_Tweet) {
655+ if (_curSearchType==eSearchType_Tweet) {
619656 [tableView deselectRowAtIndexPath: indexPath animated: YES ];
620657 [self goToTweet: _dateSource[indexPath.row]];
621658 }else if (_curSearchType==eSearchType_Project){
@@ -627,7 +664,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
627664 }else if (_curSearchType==eSearchType_Task){
628665 [self goToTask: _dateSource[indexPath.row]];
629666 }else if (_curSearchType==eSearchType_Topic){
630- [self goToTopic: _dateSource[indexPath.row]];
667+ [self goToMRDetail: _dateSource[indexPath.row]];
668+ }else if (_curSearchType==eSearchType_Merge){
669+ [self goToMRDetail: _dateSource[indexPath.row]];
631670 }
632671}
633672
0 commit comments