FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Coding-iOS/Coding_iOS/Controllers/MRPRFilesViewController.m at master · jsonwang/Coding-iOS · GitHub
jsonwang
/
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
/
MRPRFilesViewController.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
185 lines (159 loc) · 6.64 KB
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Controllers
/
MRPRFilesViewController.m
Copy path
File metadata and controls
185 lines (159 loc) · 6.64 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
//
//
MRPRFilesViewController.m
//
Coding_iOS
//
//
Created by Ease on 15/6/1.
//
Copyright (c) 2015年 Coding. All rights reserved.
//
#
import
"
MRPRFilesViewController.h
"
#
import
"
FileChangesIntroduceCell.h
"
#
import
"
FileChangeListCell.h
"
#
import
"
ODRefreshControl.h
"
#
import
"
Coding_NetAPIManager.h
"
#
import
"
FileChangeDetailViewController.h
"
@interface
MRPRFilesViewController
()<UITableViewDataSource, UITableViewDelegate>
@property
(
strong
,
nonatomic
) FileChanges *curFileChanges;
@property
(
strong
,
nonatomic
)
NSMutableDictionary
*listGroups;
@property
(
strong
,
nonatomic
)
NSMutableArray
*listGroupKeys;
@property
(
strong
,
nonatomic
) UITableView *myTableView;
@property
(
nonatomic
,
strong
) ODRefreshControl *myRefreshControl;
@end
@implementation
MRPRFilesViewController
- (
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self.
title
= [
NSString
stringWithFormat:
@"
#
%@
"
, _curMRPR.iid.stringValue];
_myTableView = ({
UITableView *tableView = [[UITableView
alloc
]
initWithFrame:
self
.view.bounds
style:
UITableViewStylePlain];
tableView.
backgroundColor
=
kColorTableBG
;
tableView.
dataSource
= self;
tableView.
delegate
= self;
tableView.
separatorStyle
= UITableViewCellSeparatorStyleNone;
[tableView
registerClass:
[FileChangesIntroduceCell
class
]
forCellReuseIdentifier:
kCellIdentifier_FileChangesIntroduceCell
];
[tableView
registerClass:
[FileChangeListCell
class
]
forCellReuseIdentifier:
kCellIdentifier_FileChangeListCell
];
[
self
.view
addSubview:
tableView];
[tableView
mas_makeConstraints:
^(MASConstraintMaker *make) {
make.
edges
.
equalTo
(self.
view
);
}];
tableView;
});
_myRefreshControl = [[ODRefreshControl
alloc
]
initInScrollView:
self
.myTableView];
[_myRefreshControl
addTarget:
self
action:
@selector
(
refresh
)
forControlEvents:
UIControlEventValueChanged];
[
self
refresh
];
}
- (
void
)
refresh
{
if
(_curMRPR.
isLoading
) {
return
;
}
if
(!_curFileChanges) {
[
self
.view
beginLoading
];
}
__weak
typeof
(self) weakSelf = self;
[[Coding_NetAPIManager
sharedManager
]
request_MRPRFileChanges_WithObj:
_curMRPR
andBlock:
^(FileChanges *data,
NSError
*error) {
[weakSelf.view
endLoading
];
[weakSelf.myRefreshControl
endRefreshing
];
if
(data) {
weakSelf.
curFileChanges
= data;
[weakSelf
configListGroups
];
[weakSelf.myTableView
reloadData
];
}
[weakSelf.view
configBlankPage:
EaseBlankPageTypeView
hasData:
(weakSelf.curFileChanges !=
nil
)
hasError:
(error !=
nil
)
reloadButtonBlock:
^(
id
sender) {
[weakSelf
refresh
];
}];
}];
}
- (
void
)
configListGroups
{
if
(!_listGroupKeys) {
_listGroupKeys = [
NSMutableArray
new
];
}
if
(!_listGroups) {
_listGroups = [
NSMutableDictionary
new
];
}
[_listGroupKeys
removeAllObjects
];
[_listGroups
removeAllObjects
];
for
(FileChange *curFileChange in _curFileChanges.
paths
) {
NSString
*curKey = curFileChange.
displayFilePath
;
NSMutableArray
*curList = [_listGroups
objectForKey:
curKey];
if
(curList.
count
>
0
) {
[curList
addObject:
curFileChange];
}
else
{
[_listGroupKeys
addObject:
curKey];
curList = [
NSMutableArray
arrayWithObject:
curFileChange];
[_listGroups
setObject:
curList
forKey:
curKey];
}
}
[_listGroupKeys
sortUsingComparator:
^
NSComparisonResult
(
NSString
*obj1,
NSString
*obj2) {
return
[obj1
compare:
obj2];
}];
}
#
pragma mark
TableM Header
- (CGFloat)
tableView
:
(UITableView *)
tableView
heightForHeaderInSection
:
(
NSInteger
)
section
{
if
(section !=
0
) {
return
kScaleFrom_iPhone5_Desgin
(
24
);
}
else
{
return
0
;
}
}
- (UIView *)
tableView
:
(UITableView *)
tableView
viewForHeaderInSection
:
(
NSInteger
)
section
{
if
(section !=
0
) {
return
[tableView
getHeaderViewWithStr:
[_listGroupKeys
objectAtIndex:
section -
1
]
andBlock:
^(
id
obj) {
NSLog
(
@"
%@
"
, [_listGroupKeys
objectAtIndex:
section -
1
]);
}];
}
else
{
return
nil
;
}
}
#
pragma mark
Table
- (
NSInteger
)
numberOfSectionsInTableView
:
(UITableView *)
tableView
{
if
(_curFileChanges) {
return
_listGroupKeys.
count
+
1
;
}
else
{
return
0
;
}
}
- (
NSInteger
)
tableView
:
(UITableView *)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
if
(section ==
0
) {
return
1
;
}
else
{
NSString
*curKey = [_listGroupKeys
objectAtIndex:
section -
1
];
NSArray
*curList = [_listGroups
objectForKey:
curKey];
return
curList.
count
;
}
}
- (UITableViewCell *)
tableView
:
(UITableView *)
tableView
cellForRowAtIndexPath
:
(
NSIndexPath
*)
indexPath
{
if
(indexPath.
section
==
0
) {
FileChangesIntroduceCell *cell = [tableView
dequeueReusableCellWithIdentifier:
kCellIdentifier_FileChangesIntroduceCell
forIndexPath:
indexPath];
[cell
setFilesCount:
_curFileChanges.paths.count
insertions:
_curFileChanges.insertions.integerValue
deletions:
_curFileChanges.deletions.integerValue];
return
cell;
}
else
{
NSString
*curKey = [_listGroupKeys
objectAtIndex:
indexPath.section -
1
];
NSArray
*curList = [_listGroups
objectForKey:
curKey];
FileChange *curFileChange = [curList
objectAtIndex:
indexPath.row];
FileChangeListCell *cell = [tableView
dequeueReusableCellWithIdentifier:
kCellIdentifier_FileChangeListCell
forIndexPath:
indexPath];
cell.
curFileChange
= curFileChange;
[tableView
addLineforPlainCell:
cell
forRowAtIndexPath:
indexPath
withLeftSpace:
50
];
return
cell;
}
}
- (CGFloat)
tableView
:
(UITableView *)
tableView
heightForRowAtIndexPath
:
(
NSIndexPath
*)
indexPath
{
if
(indexPath.
section
==
0
) {
return
[FileChangesIntroduceCell
cellHeight
];
}
else
{
return
[FileChangeListCell
cellHeight
];
}
}
- (
void
)
tableView
:
(UITableView *)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*)
indexPath
{
[tableView
deselectRowAtIndexPath:
indexPath
animated:
YES
];
if
(indexPath.
section
>
0
) {
NSString
*curKey = [_listGroupKeys
objectAtIndex:
indexPath.section -
1
];
NSArray
*curList = [_listGroups
objectForKey:
curKey];
FileChange *curFileChange = [curList
objectAtIndex:
indexPath.row];
FileChangeDetailViewController *vc = [FileChangeDetailViewController
new
];
vc.
linkUrlStr
= [
NSString
stringWithFormat:
@"
%@
?path=
%@
"
, [_curMRPR
toFileLineChangesPath
], curFileChange.path];
vc.
curProject
= _curProject;
vc.
commitId
= curFileChange.
commitId
;
vc.
filePath
= curFileChange.
path
;
vc.
noteable_id
= _curMRPRInfo.
mrpr
.
id
.
stringValue
;
[
self
.navigationController
pushViewController:
vc
animated:
YES
];
}
}
@end
Back
|
FazBrowse Home
|
New Git URL