12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // SKChatListViewController.m
- // Artimenring
- //
- // Created by 振兴 刘 on 16/4/12.
- // Copyright © 2016年 BaH Cy. All rights reserved.
- //
- #import "SKChatListViewController.h"
- #import "SKChatListViewCell.h"
- #import "DataManager.h"
- #import "SKChatConstants.h"
- #import "SKChatViewController.h"
- #import <UMMobClick/MobClick.h>
- @interface SKChatListViewController ()<UITableViewDataSource>
- @property(nonatomic, strong) IBOutlet UITableView *mTableView;
- @end
- @implementation SKChatListViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.title = NSLocalizedString(@"SKChat.Title.List", nil);
- [self.navigationController setNavigationBarHidden:NO];
- [self addMoreButtons];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:NO];
- [self requestSession];
- }
- - (void)onApplicationEnterForeground {
- [self requestSession];
- }
- - (void)onReceiveNewChat {
- if (self.isViewLoaded && self.view.window != nil) {
- [self requestSession];
- }
- }
- - (void)requestSession {
- [[DataManager shared] requestSession:^(BOOL isOK) {
- if (isOK) {
- [self.mTableView reloadData];
- }
- }];
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- BOOL isEmpty = [DataManager shared].mSessionList.count <= 0;
- [self.view isEmptyView:isEmpty emptyImageName:@"nodata_friends"];
- return [DataManager shared].mSessionList.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 78;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *cellID = @"SKChatListViewCellID";
- SKChatListViewCell *cell = (SKChatListViewCell*)[tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
- if(cell == nil) {
- cell = [[SKChatListViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
- }
-
- SessionModel* model = [[DataManager shared].mSessionList objectAtIndex:indexPath.row];
- [cell setData:model];
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [self.mTableView deselectRowAtIndexPath:indexPath animated:YES];
- [MobClick event:@"ClickChatListGotoChat"];
-
- //点击当前行后,当前行未读为0,故显示剩余行,剩余个数//
- [[DataManager shared] refreshUnreadCount:indexPath.row];
-
- SessionModel* model = [[DataManager shared].mSessionList objectAtIndex:indexPath.row];
- SKChatViewController *controller = [[self storyboard] instantiateViewControllerWithIdentifier:@"SKChatVC"];
- controller.mSessionModel = model;
- [self pushViewController:controller animated:YES];
- }
- @end
|