FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Coding-iOS/Coding_iOS/Controllers/AllSearchDisplayVC.m at master · LizardLife/Coding-iOS · GitHub
LizardLife
/
Coding-iOS
Public
forked from
coding/Coding-iOS
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Controllers
/
AllSearchDisplayVC.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
1015 lines (877 loc) · 42.1 KB
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Controllers
/
AllSearchDisplayVC.m
Copy path
File metadata and controls
1015 lines (877 loc) · 42.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
//
AllSearchDisplayVC.m
//
Coding_iOS
//
//
Created by jwill on 15/11/19.
//
Copyright © 2015年 Coding. All rights reserved.
//
#
import
"
AllSearchDisplayVC.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
AllSearchDisplayVC
() <UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource,UIScrollViewDelegate>
@property
(
nonatomic
,
strong
) UIView *contentView;
@property
(
nonatomic
,
strong
) XHRealTimeBlur *backgroundView;
@property
(
nonatomic
,
strong
) UIButton *btnMore;
@property
(
nonatomic
,
strong
) TopicHotkeyView *topicHotkeyView;
@property
(
nonatomic
,
strong
) UITableView *searchTableView;
@property
(
nonatomic
,
strong
) ODRefreshControl *refreshControl;
@property
(
nonatomic
,
strong
)
NSMutableArray
*dateSource;
@property
(
nonatomic
,
assign
)
BOOL
isLoading;
@property
(
nonatomic
,
strong
) UILabel *headerLabel;
@property
(
nonatomic
,
strong
) PublicSearchModel *searchPros;
@property
(
nonatomic
,
strong
) UIScrollView *searchHistoryView;
@property
(
nonatomic
,
assign
)
double
historyHeight;
- (
void
)
initSearchResultsTableView
;
- (
void
)
initSearchHistoryView
;
- (
void
)
didClickedMoreHotkey
:
(UIGestureRecognizer *)
sender
;
- (
void
)
didCLickedCleanSearchHistory
:
(
id
)
sender
;
- (
void
)
didClickedContentView
:
(UIGestureRecognizer *)
sender
;
- (
void
)
didClickedHistory
:
(UIGestureRecognizer *)
sender
;
@end
@implementation
AllSearchDisplayVC
- (
void
)
dealloc
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver:
self
];
_searchHistoryView.
delegate
=
nil
;
}
- (
void
)
setActive
:
(
BOOL
)
visible
animated
:
(
BOOL
)
animated
{
if
(!visible) {
[_searchTableView
removeFromSuperview
];
[_backgroundView
removeFromSuperview
];
[_contentView
removeFromSuperview
];
_searchTableView =
nil
;
_contentView =
nil
;
_backgroundView =
nil
;
_searchHistoryView =
nil
;
[
super
setActive:
visible
animated:
animated];
}
else
{
[
super
setActive:
visible
animated:
animated];
NSArray
*subViews = self.
searchContentsController
.
view
.
subviews
;
if
([[[UIDevice
currentDevice
]
systemVersion
]
floatValue
] >=
7
.
0f
) {
for
(UIView *view in subViews) {
if
([view
isKindOfClass:
NSClassFromString
(
@"
UISearchDisplayControllerContainerView
"
)]) {
NSArray
*sub = view.
subviews
;
((UIView*)sub[
2
]).
hidden
=
YES
;
}
}
}
else
{
[[subViews
lastObject
]
removeFromSuperview
];
}
if
(!_contentView) {
_contentView = ({
UIView *view = [[UIView
alloc
]
init
];
view.
frame
=
CGRectMake
(
0
.
0f
,
0
,
kScreen_Width
,
kScreen_Height
-
60
.
0f
);
view.
backgroundColor
= [UIColor
clearColor
];
view.
userInteractionEnabled
=
YES
;
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer
alloc
]
initWithTarget:
self
action:
@selector
(
didClickedContentView:
)];
[view
addGestureRecognizer:
tapGestureRecognizer];
view;
});
_backgroundView = ({
XHRealTimeBlur *blur = [[XHRealTimeBlur
alloc
]
initWithFrame:
_contentView.frame];
blur.
blurStyle
= XHBlurStyleTranslucentWhite;
blur;
});
_backgroundView.
userInteractionEnabled
=
NO
;
[
self
initSearchHistoryView
];
}
[
self
.parentVC.view
addSubview:
_backgroundView];
[
self
.parentVC.view
addSubview:
_contentView];
[
self
.parentVC.view
bringSubviewToFront:
_contentView];
self.
searchBar
.
delegate
= self;
}
}
#
pragma mark
- UI
- (
void
)
initSearchResultsTableView
{
_dateSource = [[
NSMutableArray
alloc
]
init
];
if
(!_searchTableView) {
_searchTableView = ({
UITableView *tableView = [[UITableView
alloc
]
initWithFrame:
_contentView.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
.parentVC.view
addSubview:
tableView];
self.
headerLabel
= ({
UILabel *label = [[UILabel
alloc
]
initWithFrame:
CGRectMake
(
0
,
2
,
kScreen_Width
,
44
)];
label.
backgroundColor
= [UIColor
clearColor
];
label.
textColor
= [UIColor
colorWithHexString:
@"
0x999999
"
];
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;
});
}
[_searchTableView.superview
bringSubviewToFront:
_searchTableView];
[_searchTableView
reloadData
];
[
self
refresh
];
}
- (
void
)
initSearchHistoryView
{
if
(!_searchHistoryView) {
_searchHistoryView = [[UIScrollView
alloc
]
init
];
_searchHistoryView.
backgroundColor
= [UIColor
clearColor
];
[_contentView
addSubview:
_searchHistoryView];
self.
searchBar
.
delegate
=self;
[
self
registerForKeyboardNotifications
];
}
[[_searchHistoryView
subviews
]
makeObjectsPerformSelector:
@selector
(
removeFromSuperview
)];
{
UIView *view = [[UIView
alloc
]
initWithFrame:
CGRectMake
(
0
,
0
,
kScreen_Width
,
0.5
)];
view.
backgroundColor
= [UIColor
colorWithHexString:
@"
0xdddddd
"
];
[_searchHistoryView
addSubview:
view];
}
NSArray
*array = [CSSearchModel
getSearchHistory
];
CGFloat imageLeft =
12
.
0f
;
CGFloat textLeft =
34
.
0f
;
CGFloat height =
44
.
0f
;
_historyHeight=height*(array.
count
+
1
);
//
set history list
[_searchHistoryView
mas_makeConstraints:
^(MASConstraintMaker *make) {
make.
top
.
mas_equalTo
(@
0
);
make.
left
.
mas_equalTo
(@
0
);
make.
width
.
mas_equalTo
(
kScreen_Width
);
make.
height
.
mas_equalTo
(_historyHeight);
}];
_searchHistoryView.
contentSize
=
CGSizeMake
(
kScreen_Width
, _historyHeight);
for
(
int
i =
0
; i < array.
count
; i++) {
UILabel *lblHistory = [[UILabel
alloc
]
initWithFrame:
CGRectMake
(textLeft, i * height,
kScreen_Width
- textLeft, height)];
lblHistory.
userInteractionEnabled
=
YES
;
lblHistory.
font
= [UIFont
systemFontOfSize:
14
];
lblHistory.
textColor
= [UIColor
colorWithHexString:
@"
0x222222
"
];
lblHistory.
text
= array[i];
UIImageView *leftView = [[UIImageView
alloc
]
initWithFrame:
CGRectMake
(
0
,
0
,
15
,
15
)];
leftView.
left
=
12
;
leftView.
centerY
= lblHistory.
centerY
;
leftView.
image
= [UIImage
imageNamed:
@"
icon_search_clock
"
];
UIImageView *rightImageView = [[UIImageView
alloc
]
initWithFrame:
CGRectMake
(
0
,
0
,
14
,
14
)];
rightImageView.
right
=
kScreen_Width
-
12
;
rightImageView.
centerY
= lblHistory.
centerY
;
rightImageView.
image
= [UIImage
imageNamed:
@"
icon_arrow_searchHistory
"
];
UIView *view = [[UIView
alloc
]
initWithFrame:
CGRectMake
(imageLeft, (i +
1
) * height,
kScreen_Width
- imageLeft,
0.5
)];
view.
backgroundColor
= [UIColor
colorWithHexString:
@"
0xdddddd
"
];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer
alloc
]
initWithTarget:
self
action:
@selector
(
didClickedHistory:
)];
[lblHistory
addGestureRecognizer:
tapGestureRecognizer];
[_searchHistoryView
addSubview:
lblHistory];
[_searchHistoryView
addSubview:
leftView];
[_searchHistoryView
addSubview:
rightImageView];
[_searchHistoryView
addSubview:
view];
}
if
(array.
count
) {
UIButton *btnClean = [UIButton
buttonWithType:
UIButtonTypeCustom];
btnClean.
titleLabel
.
font
= [UIFont
systemFontOfSize:
14
];
[btnClean
setTitle:
@"
清除搜索历史
"
forState:
UIControlStateNormal];
[btnClean
setTitleColor:
[UIColor
colorWithHexString:
@"
0x1bbf75
"
]
forState:
UIControlStateNormal];
[btnClean
setFrame:
CGRectMake
(
0
, array.count * height,
kScreen_Width
, height)];
[_searchHistoryView
addSubview:
btnClean];
[btnClean
addTarget:
self
action:
@selector
(
didCLickedCleanSearchHistory:
)
forControlEvents:
UIControlEventTouchUpInside];
{
UIView *view = [[UIView
alloc
]
initWithFrame:
CGRectMake
(imageLeft, (array.count +
1
) * height,
kScreen_Width
- imageLeft,
0.5
)];
view.
backgroundColor
= [UIColor
colorWithHexString:
@"
0xdddddd
"
];
[_searchHistoryView
addSubview:
view];
}
}
}
#
pragma mark
- event
- (
void
)
didClickedMoreHotkey
:
(UIGestureRecognizer *)
sender
{
[
self
.searchBar
resignFirstResponder
];
CSHotTopicPagesVC *vc = [CSHotTopicPagesVC
new
];
[
self
.parentVC.navigationController
pushViewController:
vc
animated:
YES
];
}
- (
void
)
didCLickedCleanSearchHistory
:
(
id
)
sender
{
[CSSearchModel
cleanAllSearchHistory
];
[
self
initSearchHistoryView
];
}
- (
void
)
didClickedContentView
:
(UIGestureRecognizer *)
sender
{
[
self
.searchBar
resignFirstResponder
];
}
- (
void
)
didClickedHistory
:
(UIGestureRecognizer *)
sender
{
UILabel *label = (UILabel *)sender.
view
;
self.
searchBar
.
text
= label.
text
;
[CSSearchModel
addSearchHistory:
self
.searchBar.text];
[
self
initSearchHistoryView
];
[
self
.searchBar
resignFirstResponder
];
[
self
initSearchResultsTableView
];
}
#
pragma mark
-- goVC
- (
void
)
goToProject
:
(Project *)
project
{
UIViewController *vc = [BaseViewController
analyseVCFromLinkStr:
project.project_path];
[
self
.parentVC.navigationController
pushViewController:
vc
animated:
TRUE
];
}
-(
void
)
goToTweet
:
(Tweet *)
tweet
{
TweetDetailViewController *vc = [[TweetDetailViewController
alloc
]
init
];
vc.
curTweet
= tweet;
[
self
.parentVC.navigationController
pushViewController:
vc
animated:
YES
];
}
- (
void
)
goToFileVC
:
(ProjectFile *)
file
{
UIViewController *vc = [BaseViewController
analyseVCFromLinkStr:
file.path];
[
self
.parentVC.navigationController
pushViewController:
vc
animated:
YES
];
}
- (
void
)
goToUserInfo
:
(User *)
user
{
UIViewController *vc = [BaseViewController
analyseVCFromLinkStr:
user.path];
[
self
.parentVC.navigationController
pushViewController:
vc
animated:
YES
];
}
- (
void
)
goToTask
:
(Task*)
curTask
{
NSString
*path=[
NSString
stringWithFormat:
@"
%@
/task/
%@
"
,curTask.project.project_path,curTask.
id
];
UIViewController *vc = [BaseViewController
analyseVCFromLinkStr:
path];
[
self
.parentVC.navigationController
pushViewController:
vc
animated:
YES
];
}
- (
void
)
goToTopic
:
(ProjectTopic*)
curTopic
{
NSString
*path=[
NSString
stringWithFormat:
@"
%@
/topic/
%@
"
,curTopic.project.project_path,curTopic.
id
];
UIViewController *vc = [BaseViewController
analyseVCFromLinkStr:
path];
[
self
.parentVC.navigationController
pushViewController:
vc
animated:
YES
];
}
- (
void
)
goToMRDetail
:
(
MRPR
*)
curMR
{
UIViewController *vc = [BaseViewController
analyseVCFromLinkStr:
curMR.path];
[
self
.parentVC.navigationController
pushViewController:
vc
animated:
YES
];
}
#
pragma mark
-
#
pragma mark
Search Data Request
- (
void
)
refresh
{
if
(_isLoading){
[_searchTableView.infiniteScrollingView
stopAnimating
];
return
;
}
[
self
requestAll
];
}
- (
void
)
loadMore
{
if
(_isLoading){
[_searchTableView.infiniteScrollingView
stopAnimating
];
return
;
}
//
判断分类
int
currentPage;
int
totalPage;
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
)
reloadDisplayData
{
[
self
.dateSource
removeAllObjects
];
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) {
[weakSelf
requestAll
];
}];
//
空白页按钮事件
_searchTableView.
blankPageView
.
clickButtonBlock
=^(EaseBlankPageType curType) {
[weakSelf
requestAll
];
};
[
self
refreshHeaderTitle
];
_searchTableView.
showsInfiniteScrolling
= [
self
showTotalPage
];
[
self
.searchTableView
reloadData
];
}
//
是否显示加载更多
-(
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
;
}
}
//
更新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
],
self
.searchBar.text];
}
break
;
case
eSearchType_Tweet:
if
([_searchPros.tweets.totalRow
longValue
]==
0
) {
titleStr=
nil
;
}
else
{
titleStr=[
NSString
stringWithFormat:
@"
共搜索到
%ld
个与
\"
%@
\"
相关的冒泡
"
, [_searchPros.tweets.totalRow
longValue
],
self
.searchBar.text];
}
break
;
case
eSearchType_Document:
if
([_searchPros.files.totalRow
longValue
]==
0
) {
titleStr=
nil
;
}
else
{
titleStr=[
NSString
stringWithFormat:
@"
共搜索到
%ld
个与
\"
%@
\"
相关的文档
"
, [_searchPros.files.totalRow
longValue
],
self
.searchBar.text];
}
break
;
case
eSearchType_User:
if
([_searchPros.friends.totalRow
longValue
]==
0
) {
titleStr=
nil
;
}
else
{
titleStr=[
NSString
stringWithFormat:
@"
共搜索到
%ld
个与
\"
%@
\"
相关的用户
"
, [_searchPros.friends.totalRow
longValue
],
self
.searchBar.text];
}
break
;
case
eSearchType_Task:
if
([_searchPros.tasks.totalRow
longValue
]==
0
) {
titleStr=
nil
;
}
else
{
titleStr=[
NSString
stringWithFormat:
@"
共搜索到
%ld
个与
\"
%@
\"
相关的任务
"
, [_searchPros.tasks.totalRow
longValue
],
self
.searchBar.text];
}
break
;
case
eSearchType_Topic:
if
([_searchPros.project_topics.totalRow
longValue
]==
0
) {
titleStr=
nil
;
}
else
{
titleStr=[
NSString
stringWithFormat:
@"
共搜索到
%ld
个与
\"
%@
\"
相关的讨论
"
, [_searchPros.project_topics.totalRow
longValue
],
self
.searchBar.text];
}
break
;
case
eSearchType_Merge:
if
([_searchPros.merge_requests.totalRow
longValue
]==
0
) {
titleStr=
nil
;
}
else
{
titleStr=[
NSString
stringWithFormat:
@"
共搜索到
%ld
个与
\"
%@
\"
相关的合并请求
"
, [_searchPros.merge_requests.totalRow
longValue
],
self
.searchBar.text];
}
break
;
case
eSearchType_Pull:
if
([_searchPros.pull_requests.totalRow
longValue
]==
0
) {
titleStr=
nil
;
}
else
{
titleStr=[
NSString
stringWithFormat:
@"
共搜索到
%ld
个与
\"
%@
\"
相关的pull请求
"
, [_searchPros.pull_requests.totalRow
longValue
],
self
.searchBar.text];
}
break
;
default
:
break
;
}
self.
headerLabel
.
text
=titleStr;
}
-(
void
)
requestAll
{
__weak
typeof
(self) weakSelf = self;
[[Coding_NetAPIManager
sharedManager
]
requestWithSearchString:
self
.searchBar.text
typeStr:
@"
all
"
andPage:
1
andBlock:
^(
id
data,
NSError
*error) {
if
(data) {
[weakSelf.dateSource
removeAllObjects
];
weakSelf.
searchPros
= [
NSObject
objectOfClass:
@"
PublicSearchModel
"
fromJSON:
data];
NSDictionary
*dataDic = (
NSDictionary
*)data;
//
topic 处理 content 关键字
NSArray
*resultTopic =[dataDic[
@"
project_topics
"
]
objectForKey:
@"
list
"
] ;
for
(
int
i=
0
;i<[_searchPros.project_topics.list
count
];i++) {
ProjectTopic *curTopic=[_searchPros.project_topics.list
objectAtIndex:
i];
if
([resultTopic
count
]>i) {
curTopic.
contentStr
= [[[resultTopic
objectAtIndex:
i]
objectForKey:
@"
content
"
]
firstObject
];
}
}
//
task 处理 description 关键字
NSArray
*resultTask =[dataDic[
@"
tasks
"
]
objectForKey:
@"
list
"
] ;
for
(
int
i=
0
;i<[weakSelf.searchPros.tasks.list
count
];i++) {
Task *curTask=[weakSelf.searchPros.tasks.list
objectAtIndex:
i];
if
([resultTask
count
]>i) {
curTask.
descript
= [[[resultTask
objectAtIndex:
i]
objectForKey:
@"
description
"
]
firstObject
];
}
}
switch
(weakSelf.
curSearchType
) {
case
eSearchType_Project:
[weakSelf.dateSource
addObjectsFromArray:
weakSelf.searchPros.projects.list];
break
;
case
eSearchType_Tweet:
[weakSelf.dateSource
addObjectsFromArray:
weakSelf.searchPros.tweets.list];
break
;
case
eSearchType_Document:
[weakSelf.dateSource
addObjectsFromArray:
weakSelf.searchPros.files.list];
break
;
case
eSearchType_User:
[weakSelf.dateSource
addObjectsFromArray:
weakSelf.searchPros.friends.list];
break
;
case
eSearchType_Task:
[weakSelf.dateSource
addObjectsFromArray:
weakSelf.searchPros.tasks.list];
break
;
case
eSearchType_Topic:
[weakSelf.dateSource
addObjectsFromArray:
weakSelf.searchPros.project_topics.list];
break
;
case
eSearchType_Merge:
[weakSelf.dateSource
addObjectsFromArray:
weakSelf.searchPros.merge_requests.list];
break
;
case
eSearchType_Pull:
[weakSelf.dateSource
addObjectsFromArray:
weakSelf.searchPros.pull_requests.list];
break
;
default
:
break
;
}
[weakSelf.searchTableView
configBlankPage:
EaseBlankPageTypeProject_SEARCH
hasData:
[weakSelf
noEmptyList
]
hasError:
(error !=
nil
)
reloadButtonBlock:
^(
id
sender) {
}];
[weakSelf.searchTableView
reloadData
];
[weakSelf.searchTableView.infiniteScrollingView
stopAnimating
];
weakSelf.
searchTableView
.
showsInfiniteScrolling
= [weakSelf
showTotalPage
];
}
weakSelf.
isLoading
=
NO
;
[
self
refreshHeaderTitle
];
}];
}
- (
void
)
requestDataWithPage
:
(
NSInteger
)
page
{
_isLoading =
YES
;
__weak
typeof
(self) weakSelf = self;
if
(_curSearchType==eSearchType_Tweet) {
[[Coding_NetAPIManager
sharedManager
]
requestWithSearchString:
self
.searchBar.text
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:
self
.searchBar.text
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:
self
.searchBar.text
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:
self
.searchBar.text
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:
self
.searchBar.text
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:
self
.searchBar.text
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:
self
.searchBar.text
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:
self
.searchBar.text
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
;
}
}
- (
void
)
analyseLinkStr
:
(
NSString
*)
linkStr
{
if
(linkStr.
length
<=
0
) {
return
;
}
UIViewController *vc = [BaseViewController
analyseVCFromLinkStr:
linkStr];
if
(vc) {
[
self
.parentVC.navigationController
pushViewController:
vc
animated:
YES
];
}
else
{
//
网页
WebViewController *webVc = [WebViewController
webVCWithUrlStr:
linkStr];
[
self
.parentVC.navigationController
pushViewController:
webVc
animated:
YES
];
}
}
- (
void
)
registerForKeyboardNotifications
{
//
使用NSNotificationCenter 鍵盤出現時
[[
NSNotificationCenter
defaultCenter
]
addObserver:
self
selector:
@selector
(
keyboardWasShown
)
name:
UIKeyboardDidShowNotification
object:
nil
];
//
使用NSNotificationCenter 鍵盤隐藏時
[[
NSNotificationCenter
defaultCenter
]
addObserver:
self
selector:
@selector
(
keyboardWillBeHidden
)
name:
UIKeyboardWillHideNotification
object:
nil
];
}
-(
void
)
keyboardWasShown
{
if
(_historyHeight+
236
>(
kScreen_Height
-
64
)) {
[_searchHistoryView
setHeight:
kScreen_Height
-
236
-
64
];
}
}
-(
void
)
keyboardWillBeHidden
{
if
(_historyHeight+
236
>(
kScreen_Height
-
64
)) {
[_searchHistoryView
setHeight:
_historyHeight];
}
}
#
pragma mark
- UISearchBarDelegate Support
- (
void
)
searchBarSearchButtonClicked
:
(UISearchBar *)
searchBar
{
[CSSearchModel
addSearchHistory:
searchBar.text];
[
self
initSearchHistoryView
];
[
self
.searchBar
resignFirstResponder
];
[
self
initSearchResultsTableView
];
}
#
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) {
ConversationViewController *vc = [[ConversationViewController
alloc
]
init
];
User *copyUser=[curUser
copy
];
copyUser.
name
=[
NSString
getStr:
copyUser.name
removeEmphasize:
@"
em
"
];
copyUser.
global_key
=[
NSString
getStr:
copyUser.global_key
removeEmphasize:
@"
em
"
];
copyUser.
pinyinName
=[
NSString
getStr:
copyUser.pinyinName
removeEmphasize:
@"
em
"
];
vc.
myPriMsgs
= [PrivateMessages
priMsgsWithUser:
copyUser];
[weakSelf.parentVC.navigationController
pushViewController:
vc
animated:
YES
];
};
[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
nil
;
}
}
- (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
(_curSearchType==eSearchType_Tweet) {
[
self
goToTweet:
_dateSource[indexPath.row]];
}
else
if
(_curSearchType==eSearchType_Project){
[
self
goToProject:
_dateSource[indexPath.row]];
}
else
if
(_curSearchType==eSearchType_Document){
[
self
goToFileVC:
_dateSource[indexPath.row]];
}
else
if
(_curSearchType==eSearchType_User){
[
self
goToUserInfo:
_dateSource[indexPath.row]];
}
else
if
(_curSearchType==eSearchType_Task){
[
self
goToTask:
_dateSource[indexPath.row]];
}
else
if
(_curSearchType==eSearchType_Topic){
[
self
goToTopic:
_dateSource[indexPath.row]];
}
else
if
(_curSearchType==eSearchType_Merge){
[
self
goToMRDetail:
_dateSource[indexPath.row]];
}
else
if
(_curSearchType==eSearchType_Pull){
[
self
goToMRDetail:
_dateSource[indexPath.row]];
}
}
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL