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
//
// ForumViewController.m
// Lighting
//
// Created by 曹云霄 on 2016/11/24.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "ForumViewController.h"
#import "ForumTableViewCell.h"
#import "ForumItemListViewController.h"
@interface ForumViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
@property (nonatomic,strong) ForumCategoryResponse *category;
@end
@implementation ForumViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpForumTableView];
[self setUpRefreshAction];
}
#pragma mark - UITableView
- (void)setUpForumTableView
{
self.forumTableView.tableFooterView = [UIView new];
self.forumTableView.rowHeight = 90;
[Notification addObserver:self selector:@selector(refreshForumList:) name:REFRESH_FROUMLIST object:nil];
}
#pragma mark -选中时间轴刷新列表
- (void)refreshForumList:(NSNotification *)object
{
self.typeId = object.object;
[self.forumTableView.mj_header beginRefreshing];
}
#pragma mark - 设置刷新
- (void)setUpRefreshAction
{
WS(weakSelf);
MjRefreshHeaderCustom *headerRefresh = [MjRefreshHeaderCustom headerWithRefreshingBlock:^{
[weakSelf getForumAllTypeAction];
}];
headerRefresh.stateLabel.hidden = YES;
headerRefresh.lastUpdatedTimeLabel.hidden = YES;
self.forumTableView.mj_header =headerRefresh;
}
#pragma mark - 获取论坛项Type
- (void)getForumAllTypeAction
{
WS(weakSelf);
[XBLoadingView showHUDViewWithDefault];;
[HTTP networkWithDictionaryRequestWithURL:[NSString stringWithFormat:SERVERREQUESTURL(FORUMCATEGORYS),self.typeId] withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
[XBLoadingView hideHUDViewWithDefault];
[weakSelf endRefreshingForTableView:weakSelf.forumTableView];
weakSelf.forumTableView.emptyDataSetDelegate = weakSelf;
weakSelf.forumTableView.emptyDataSetSource = weakSelf;
if (RESULT(returnValue)) {
weakSelf.category = [[ForumCategoryResponse alloc] initWithDictionary:RESPONSE(returnValue) error:nil];
[weakSelf.forumTableView reloadData];
}else{
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
} withFailureBlock:^(NSError *error) {
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
}
#pragma mark - <UITableViewDelegate,UITableViewDataSource>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ForumTableViewCell *forumCell = [tableView dequeueReusableCellWithIdentifier:@"ForumTableViewCell" forIndexPath:indexPath];
forumCell.categoryEntity = self.category.categories[indexPath.row];
return forumCell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.category.categories.count;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ForumItemListViewController *itemListVc = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"ForumItemListViewController"];
TOForumCategoryEntity *category = self.category.categories[indexPath.row];
category.typeId = self.typeId;
itemListVc.category = category;
itemListVc.isPosting = [category.name isEqualToString:@"欧普问问"]?0:1;
[self.navigationController pushViewController:itemListVc animated:YES];
}
#pragma mark -释放
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark -友好界面
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
return kNoDataImage;
}
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView
{
return YES;
}
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
return 64.0;
}
@end