LVCVodPlayerListController.m
4.29 KB
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
//
// LVCVodPlayerListController.m
// LiveVideoCloud
//
// Created by cnliveJunBo on 17/6/27.
// Copyright © 2017年 cnlive. All rights reserved.
//
#import "LVCVodPlayerListController.h"
static NSString *vodCellId = @"vodCellId";
@interface LVCVodPlayerListController ()<UITableViewDelegate, UITableViewDataSource> {
AFHTTPRequestOperation *_operation;
NSMutableArray *_programArrayM;
}
@property (nonatomic, strong)UITableView *tableView;
@end
@implementation LVCVodPlayerListController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"点播";
self.view.backgroundColor = [UIColor whiteColor];
_programArrayM = [[NSMutableArray alloc] init];
}
- (void)requestVodPlayerList {
NSString *uid;
if ([UserTools isLogin]) {
uid = [UserInformationModel manager].uid;
} else {
uid = [NSString stringWithFormat:@"%u", arc4random()%3];
}
NSString *tm = [NSString stringWithFormat:@"%u_%@", arc4random()%10, uid];
NSDictionary *parameter = @{@"cid": @"82_news/",
@"page": [NSString stringWithFormat:@"%d", 1],
@"pagesize": @"15",
@"tm": tm};
[[AFHTTPRequestOperationManager manager] GET:Newslist parameters:[self addParameters:parameter] success:^(AFHTTPRequestOperation *operation, id responseObject) {
responseObject = [responseObject validatedDictionary];
if (responseObject[@"programs"] && [responseObject[@"programs"] isKindOfClass:[NSArray class]]) {
for (NSDictionary *dic in responseObject[@"programs"]) {
ProgramModel *programModel = [ProgramModel modelWithDic:dic];
[_programArrayM addObject:programModel];
if (dic[@"comments"] && [dic[@"comments"] isKindOfClass:[NSArray class]] && [dic[@"comments"] count] > 0) {
NSMutableArray *comments = [[NSMutableArray alloc] init];
for (NSDictionary *commentDic in dic[@"comments"]) {
LVCCommentModel *commentModel = [LVCCommentModel modelWithDic:commentDic];
[comments addObject:commentModel];
}
[_programArrayM addObject:comments];
}
}
}
[self.tableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"点播列表请求失败!");
}];
}
#pragma mark - UITableViewDelegate !!!!!!!!!!!!!!!!!!!!!!!!
#pragma mark - UITableViewDataSource !!!!!!!!!!!!!!!!!!!!!!!!
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _programArrayM.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
return nil;
}
#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, -KScreenHeight, KScreenWidth, KScreenHeight)];
view.backgroundColor = [UIColor backgroundColor];
[_tableView addSubview:view];
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:vodCellId];
}
return _tableView;
}
#pragma mark ------------------------------ 分割线 ----------------------------------------------
- (NSDictionary *)addParameters:(NSDictionary *)dict {
if (![dict isKindOfClass:[NSDictionary class]]) {
return dict;
}
if (!dict) {
return @{@"appid": JBAppId, @"plat": @"i", @"version": JBAppVersion};
} else {
NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithDictionary:dict];
[dic addEntriesFromDictionary:@{@"appid": JBAppId, @"plat": @"i", @"version": JBAppVersion}];
return [[NSDictionary alloc] initWithDictionary:dic];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end