66// Copyright (c) 2014年 Coding. All rights reserved.
77//
88
9+ #define kTopItemNum 1
10+
911#import " Message_RootViewController.h"
1012#import " ODRefreshControl.h"
1113#import " Coding_NetAPIManager.h"
@@ -24,7 +26,7 @@ @interface Message_RootViewController ()
2426@property (nonatomic , strong ) UITableView *myTableView;
2527@property (nonatomic , strong ) ODRefreshControl *refreshControl;
2628@property (strong , nonatomic ) PrivateMessages *myPriMsgs;
27- @property (strong , nonatomic ) NSMutableDictionary *notificationDict;
29+ // @property (strong, nonatomic) NSMutableDictionary *notificationDict;
2830@end
2931
3032@implementation Message_RootViewController
@@ -120,16 +122,16 @@ - (void)sendMsgBtnClicked:(id)sender{
120122}
121123
122124- (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+ // }];
133135 [[UnReadManager shareManager ] updateUnRead ];
134136
135137 if (_myPriMsgs.isLoading ) {
@@ -156,7 +158,7 @@ - (void)sendRequest_PrivateMessages{
156158 [weakSelf.myPriMsgs configWithObj: data];
157159 [weakSelf.myTableView reloadData ];
158160 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) {
160162 [weakSelf refresh ];
161163 }];
162164 }
@@ -165,35 +167,37 @@ - (void)sendRequest_PrivateMessages{
165167
166168#pragma mark Table M
167169- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
168- NSInteger row = 3 ;
170+ NSInteger row = kTopItemNum ;
169171 if (_myPriMsgs.list ) {
170172 row += [_myPriMsgs.list count ];
171173 }
172174 return row;
173175}
174176
175177- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
176- if (indexPath.row < 3 ) {
178+ if (indexPath.row < kTopItemNum ) {
177179 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+ // }
192196 [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 75 hasSectionLine: NO ];
193197 return cell;
194198 }else {
195199 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 ];
197201 cell.curPriMsg = msg;
198202 [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: 75 hasSectionLine: NO ];
199203 return cell;
@@ -202,7 +206,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
202206
203207- (CGFloat)tableView : (UITableView *)tableView heightForRowAtIndexPath : (NSIndexPath *)indexPath {
204208 CGFloat cellHeight;
205- if (indexPath.row < 3 ) {
209+ if (indexPath.row < kTopItemNum ) {
206210 cellHeight = [ToMessageCell cellHeight ];
207211 }else {
208212 cellHeight = [ConversationCell cellHeight ];
@@ -212,12 +216,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
212216
213217- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
214218 [tableView deselectRowAtIndexPath: indexPath animated: YES ];
215- if (indexPath.row < 3 ) {
219+ if (indexPath.row < kTopItemNum ) {
216220 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];
218223 [self .navigationController pushViewController: vc animated: YES ];
219224 }else {
220- PrivateMessage *curMsg = [_myPriMsgs.list objectAtIndex: indexPath.row-3 ];
225+ PrivateMessage *curMsg = [_myPriMsgs.list objectAtIndex: indexPath.row-kTopItemNum ];
221226 ConversationViewController *vc = [[ConversationViewController alloc ] init ];
222227 User *curFriend = curMsg.friend ;
223228
@@ -231,11 +236,11 @@ - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButto
231236 return @" 删除会话" ;
232237}
233238- (BOOL )tableView : (UITableView *)tableView canEditRowAtIndexPath : (NSIndexPath *)indexPath {
234- return (indexPath.row >= 3 );
239+ return (indexPath.row >= kTopItemNum );
235240}
236241- (void )tableView : (UITableView *)tableView commitEditingStyle : (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath : (NSIndexPath *)indexPath {
237242 [tableView setEditing: NO animated: YES ];
238- PrivateMessage *msg = [_myPriMsgs.list objectAtIndex: indexPath.row-3 ];
243+ PrivateMessage *msg = [_myPriMsgs.list objectAtIndex: indexPath.row-kTopItemNum ];
239244
240245 __weak typeof (self) weakSelf = self;
241246 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
253258 if (data) {
254259 [weakSelf.myPriMsgs.list removeObject: data];
255260 [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) {
257262 [weakSelf refresh ];
258263 }];
259264 }
0 commit comments