6
6
// Copyright (c) 2014年 Coding. All rights reserved.
7
7
//
8
8
9
+ #define kTopItemNum 1
10
+
9
11
#import " Message_RootViewController.h"
10
12
#import " ODRefreshControl.h"
11
13
#import " Coding_NetAPIManager.h"
@@ -24,7 +26,7 @@ @interface Message_RootViewController ()
24
26
@property (nonatomic , strong ) UITableView *myTableView;
25
27
@property (nonatomic , strong ) ODRefreshControl *refreshControl;
26
28
@property (strong , nonatomic ) PrivateMessages *myPriMsgs;
27
- @property (strong , nonatomic ) NSMutableDictionary *notificationDict;
29
+ // @property (strong, nonatomic) NSMutableDictionary *notificationDict;
28
30
@end
29
31
30
32
@implementation Message_RootViewController
@@ -120,16 +122,16 @@ - (void)sendMsgBtnClicked:(id)sender{
120
122
}
121
123
122
124
- (void )refresh {
123
- __weak typeof (self) weakSelf = self;
124
- [[Coding_NetAPIManager sharedManager ] request_UnReadNotificationsWithBlock: ^(id data, NSError *error) {
125
- if (data) {
126
- weakSelf.notificationDict = [NSMutableDictionary dictionaryWithDictionary: data];
127
- [weakSelf.myTableView reloadData ];
128
- [weakSelf.myTableView configBlankPage: EaseBlankPageTypeMessageList hasData: (weakSelf.myPriMsgs.list.count > 0 ) hasError: (error != nil ) offsetY: (3 * [ToMessageCell cellHeight ]) reloadButtonBlock: ^(id sender) {
129
- [weakSelf refresh ];
130
- }];
131
- }
132
- }];
125
+ // __weak typeof(self) weakSelf = self;
126
+ // [[Coding_NetAPIManager sharedManager] request_UnReadNotificationsWithBlock:^(id data, NSError *error) {
127
+ // if (data) {
128
+ // weakSelf.notificationDict = [NSMutableDictionary dictionaryWithDictionary:data];
129
+ // [weakSelf.myTableView reloadData];
130
+ // [weakSelf.myTableView configBlankPage:EaseBlankPageTypeMessageList hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:(error != nil) offsetY:(kTopItemNum * [ToMessageCell cellHeight]) reloadButtonBlock:^(id sender) {
131
+ // [weakSelf refresh];
132
+ // }];
133
+ // }
134
+ // }];
133
135
[[UnReadManager shareManager ] updateUnRead ];
134
136
135
137
if (_myPriMsgs.isLoading ) {
@@ -156,7 +158,7 @@ - (void)sendRequest_PrivateMessages{
156
158
[weakSelf.myPriMsgs configWithObj: data];
157
159
[weakSelf.myTableView reloadData ];
158
160
weakSelf.myTableView .showsInfiniteScrolling = weakSelf.myPriMsgs .canLoadMore ;
159
- [weakSelf.myTableView configBlankPage: EaseBlankPageTypeMessageList hasData: (weakSelf.myPriMsgs.list.count > 0 ) hasError: (error != nil ) offsetY: (3 * [ToMessageCell cellHeight ]) reloadButtonBlock: ^(id sender) {
161
+ [weakSelf.myTableView configBlankPage: EaseBlankPageTypeMessageList hasData: (weakSelf.myPriMsgs.list.count > 0 ) hasError: (error != nil ) offsetY: (kTopItemNum * [ToMessageCell cellHeight ]) reloadButtonBlock: ^(id sender) {
160
162
[weakSelf refresh ];
161
163
}];
162
164
}
@@ -165,35 +167,37 @@ - (void)sendRequest_PrivateMessages{
165
167
166
168
#pragma mark Table M
167
169
- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
168
- NSInteger row = 3 ;
170
+ NSInteger row = kTopItemNum ;
169
171
if (_myPriMsgs.list ) {
170
172
row += [_myPriMsgs.list count ];
171
173
}
172
174
return row;
173
175
}
174
176
175
177
- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
176
- if (indexPath.row < 3 ) {
178
+ if (indexPath.row < kTopItemNum ) {
177
179
ToMessageCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_ToMessage forIndexPath: indexPath];
178
- switch (indexPath.row ) {
179
- case 0 :
180
- cell.type = ToMessageTypeAT;
181
- cell.unreadCount = [_notificationDict objectForKey: kUnReadKey_notification_AT ];
182
- break ;
183
- case 1 :
184
- cell.type = ToMessageTypeComment;
185
- cell.unreadCount = [_notificationDict objectForKey: kUnReadKey_notification_Comment ];
186
- break ;
187
- default :
188
- cell.type = ToMessageTypeSystemNotification;
189
- cell.unreadCount = [_notificationDict objectForKey: kUnReadKey_notification_System ];
190
- break ;
191
- }
180
+ cell.type = ToMessageTypeAllNotification;
181
+ cell.unreadCount = [UnReadManager shareManager ].notifications ;
182
+ // switch (indexPath.row) {
183
+ // case 0:
184
+ // cell.type = ToMessageTypeAT;
185
+ // cell.unreadCount = [_notificationDict objectForKey:kUnReadKey_notification_AT];
186
+ // break;
187
+ // case 1:
188
+ // cell.type = ToMessageTypeComment;
189
+ // cell.unreadCount = [_notificationDict objectForKey:kUnReadKey_notification_Comment];
190
+ // break;
191
+ // default:
192
+ // cell.type = ToMessageTypeSystemNotification;
193
+ // cell.unreadCount = [_notificationDict objectForKey:kUnReadKey_notification_System];
194
+ // break;
195
+ // }
192
196
[tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 75 hasSectionLine: NO ];
193
197
return cell;
194
198
}else {
195
199
ConversationCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_Conversation forIndexPath: indexPath];
196
- PrivateMessage *msg = [_myPriMsgs.list objectAtIndex: indexPath.row-3 ];
200
+ PrivateMessage *msg = [_myPriMsgs.list objectAtIndex: indexPath.row-kTopItemNum ];
197
201
cell.curPriMsg = msg;
198
202
[tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 75 hasSectionLine: NO ];
199
203
return cell;
@@ -202,7 +206,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
202
206
203
207
- (CGFloat)tableView : (UITableView *)tableView heightForRowAtIndexPath : (NSIndexPath *)indexPath {
204
208
CGFloat cellHeight;
205
- if (indexPath.row < 3 ) {
209
+ if (indexPath.row < kTopItemNum ) {
206
210
cellHeight = [ToMessageCell cellHeight ];
207
211
}else {
208
212
cellHeight = [ConversationCell cellHeight ];
@@ -212,12 +216,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
212
216
213
217
- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
214
218
[tableView deselectRowAtIndexPath: indexPath animated: YES ];
215
- if (indexPath.row < 3 ) {
219
+ if (indexPath.row < kTopItemNum ) {
216
220
TipsViewController *vc = [[TipsViewController alloc ] init ];
217
- vc.myCodingTips = [CodingTips codingTipsWithType: indexPath.row];
221
+ // vc.myCodingTips = [CodingTips codingTipsWithType:indexPath.row];
222
+ vc.myCodingTips = [CodingTips codingTipsWithType: ToMessageTypeAllNotification];
218
223
[self .navigationController pushViewController: vc animated: YES ];
219
224
}else {
220
- PrivateMessage *curMsg = [_myPriMsgs.list objectAtIndex: indexPath.row-3 ];
225
+ PrivateMessage *curMsg = [_myPriMsgs.list objectAtIndex: indexPath.row-kTopItemNum ];
221
226
ConversationViewController *vc = [[ConversationViewController alloc ] init ];
222
227
User *curFriend = curMsg.friend ;
223
228
@@ -231,11 +236,11 @@ - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButto
231
236
return @" 删除会话" ;
232
237
}
233
238
- (BOOL )tableView : (UITableView *)tableView canEditRowAtIndexPath : (NSIndexPath *)indexPath {
234
- return (indexPath.row >= 3 );
239
+ return (indexPath.row >= kTopItemNum );
235
240
}
236
241
- (void )tableView : (UITableView *)tableView commitEditingStyle : (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath : (NSIndexPath *)indexPath {
237
242
[tableView setEditing: NO animated: YES ];
238
- PrivateMessage *msg = [_myPriMsgs.list objectAtIndex: indexPath.row-3 ];
243
+ PrivateMessage *msg = [_myPriMsgs.list objectAtIndex: indexPath.row-kTopItemNum ];
239
244
240
245
__weak typeof (self) weakSelf = self;
241
246
UIActionSheet *actionSheet = [UIActionSheet bk_actionSheetCustomWithTitle: [NSString stringWithFormat: @" 这将删除你和 %@ 的所有私信" , msg.friend.name] buttonTitles: nil destructiveTitle: @" 确认删除" cancelTitle: @" 取消" andDidDismissBlock: ^(UIActionSheet *sheet, NSInteger index) {
@@ -253,7 +258,7 @@ - (void)removeConversation:(PrivateMessage *)curMsg inTableView:(UITableView *)t
253
258
if (data) {
254
259
[weakSelf.myPriMsgs.list removeObject: data];
255
260
[weakSelf.myTableView reloadData ];
256
- [weakSelf.myTableView configBlankPage: EaseBlankPageTypeMessageList hasData: (weakSelf.myPriMsgs.list.count > 0 ) hasError: (error != nil ) offsetY: (3 * [ToMessageCell cellHeight ]) reloadButtonBlock: ^(id sender) {
261
+ [weakSelf.myTableView configBlankPage: EaseBlankPageTypeMessageList hasData: (weakSelf.myPriMsgs.list.count > 0 ) hasError: (error != nil ) offsetY: (kTopItemNum * [ToMessageCell cellHeight ]) reloadButtonBlock: ^(id sender) {
257
262
[weakSelf refresh ];
258
263
}];
259
264
}
0 commit comments