CNLiveSubSegmentController.m
30.3 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
//
// CNLiveSubSegmentController.m
// CNLiveVideoClassifyKit
//
// Created by CNLive on 2021/8/30.
//
#import "CNLiveSubSegmentController.h"
#import "CNAudioPlayProgressView.h"
#import "CNLiveListManager.h"
#import "CNLiveListController.h"
@interface CNLiveSubSegmentController ()
@property (nonatomic, strong)JXCategoryTitleView *myCategoryView;
@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
@property (nonatomic, strong) QMUIButton *searchBtn;
@property (nonatomic, strong) UIButton *moreBtn;
@property (nonatomic, strong) UIImageView *bgImgView;//背景图
@property (nonatomic, strong) CNAudioPlayProgressView *progressView;//听见中国二级频道当前播放音乐的进度
@property (nonatomic, strong) UIButton *playingBtn;//听见中国二级频道当前播放音乐按钮
@property (nonatomic, strong) UIImageView *playingImgV;//听见中国二级频道当前播放音乐背景图
@property (nonatomic, strong) UIImageView *playTipImgV;//听见中国二级频道当前播放tip
@property (nonatomic, strong) UIButton *historyBtn;//历史记录
@property (nonatomic, strong) UIButton *downloadingBtn;//听见中国下载按钮
@property (nonatomic, strong)NSArray<CNCategoryGetChannelModel*> *pageListArr;
@property (nonatomic, strong)UIColor *textColor;
@property (nonatomic, strong)NSString *backgroundColor;
@property (nonatomic, strong)NSString *backImage;
@property (nonatomic, strong)NSString *backImageH5;
@property (nonatomic, strong)NSString *channelId;
@end
@implementation CNLiveSubSegmentController
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(instancetype)initWithModel:(CNCategoryGetChannelModel *)model
{
self = [super init];
if(self){
self.pageListArr = model.pageStyleList;
if (!CNLiveStringIsEmpty(model.textColor)) {
self.textColor = CNLiveColorWithHexString(model.textColor);
}else
{
self.textColor = CNLiveColorWithHexString(@"#848494");
}
if (!CNLiveStringIsEmpty(model.backgroundColor)) {
self.backgroundColor = model.backgroundColor;
}else
{
self.backgroundColor = @"#FFFFFF";
}
self.backImageH5 = model.backgroundImgH5;
self.backImage = model.backgroundImg;
self.channelId = model.id;
self.title = model.showName;
self.ld_currentIndex = 0;
self.selectChannelId = -1;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
if (!CNLiveStringIsEmpty(self.backImageH5)) {
// 如果后台传了背景图 就设置背景图
[self.view addSubview:self.bgImgView];
[self.view sendSubviewToBack:self.bgImgView];
weakself
[self.bgImgView sd_setImageWithURL:[NSURL URLWithString:self.backImageH5] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (image) {
if (self.showType == CNLiveSubVCShowtypeChannel) {
weakSelf.bgImgView.height = KScreenWidth*image.size.height/image.size.width + 50;
}else{
weakSelf.bgImgView.height = KScreenWidth*image.size.height/image.size.width;
}
}
}];
}
[self handleDateWithChannelsArray];
if ([CNWebRedirectHandle manager].isClickedIntegral) {
[CNWebRedirectHandle manager].isClickedIntegral = NO;
self.ld_currentIndex = [CNWebRedirectHandle manager].classifyId;
[CNWebRedirectHandle manager].classifyId = 0;
}else if (self.selectChannelId != -1) {
NSString *classifyId = [BHConfig get:ChannelsSelectSecond];
[BHConfig set:ChannelsSelectSecond value:@""];
if (!CNLiveStringIsEmpty(classifyId)) {
NSInteger selectChannelId = [self containsWithChannelIndex:self.selectChannelId classifyId:classifyId];
if(selectChannelId == -1){
//我的频道中没有这个频道
} else {
self.ld_currentIndex = selectChannelId;
}
}
}
self.view.backgroundColor = [UIColor clearColor];
self.myCategoryView.titles = self.titles;
if (CNLiveStringIsEmpty(self.backImage)) {
self.view.backgroundColor = CNLiveColorWithHexString(self.backgroundColor);
}
self.myCategoryView.titleColor = self.textColor;
self.myCategoryView.titleSelectedColor = self.textColor;
self.myCategoryView.cellSpacing = 32;
self.myCategoryView.contentEdgeInsetLeft = 25;
self.myCategoryView.averageCellSpacingEnabled = NO;
self.myCategoryView.titleFont = [UIFont fontWithName:@"PingFangSC-Medium" size:14];
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
lineView.indicatorWidth = 18;
lineView.indicatorColor = self.textColor;
self.myCategoryView.indicators = @[lineView];
if (!self.ld_currentIndex) {
self.ld_currentIndex = 0;
}
self.categoryView.defaultSelectedIndex = self.ld_currentIndex;
if (self.showType == CNLiveSubVCShowtypeClassify) {
self.listContainerView.scrollView.scrollEnabled = NO;
// 添加二级频道右侧的搜索按钮
[self.view addSubview:self.searchBtn];
if ([self.channelId isEqualToString:@"219"]) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlayingStatus:) name:WjjAudioPlayerStatusNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlayingSchedule:) name:WjjAudioPlayerScheduleNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioPlayFinishedUpdateSchedule:) name:WjjAudioPlayDidFinishNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioPlayUpdateInfo:) name:WjjAudioPlayerWhichPlayingNotification object:nil];
[self.view addSubview:self.moreBtn];
[self.view addSubview:self.progressView];
[self.progressView addSubview:self.playingImgV];
[self.playingImgV addSubview:self.playTipImgV];
[self.progressView addSubview:self.playingBtn];
YYCache * yyCache = [YYCache cacheWithName:[NSString stringWithFormat:@"CNLastPlayedAudio_%@",CNUserShareModel.uid]];
CNLiveAlbumAudioListModelModule *model = (CNLiveAlbumAudioListModelModule *)[yyCache objectForKey:[NSString stringWithFormat:@"%@_%@",wjjLastAudioInfoSaveKey,CNUserShareModel.uid]];
if (model) {
if (model && !CNLiveStringIsEmpty(model.activityId)) {
self.playingBtn.userInteractionEnabled = YES;
self.progressView.hidden = NO;
} else {
self.playingBtn.userInteractionEnabled = NO;
self.progressView.hidden = YES;
}
if (model && (!CNLiveStringIsEmpty(model.img) || !CNLiveStringIsEmpty(model.poster) || !CNLiveStringIsEmpty(model.albumImg)) ) {
[self.playingImgV sd_setImageWithURL:[NSURL URLWithString:model.img?[model.img stringByRemovingPercentEncoding]:(model.poster?[model.poster stringByRemovingPercentEncoding]:[model.albumImg stringByRemovingPercentEncoding])] placeholderImage:[UIImage loadBundleImage:@""]];
} else {
self.playingImgV.image = nil;
}
if ([CNLiveClassifyJumpBridge audioPlayerIsplaying]) {
self.playTipImgV.hidden = YES;
[self playingStartAnimating];
} else {
self.playTipImgV.hidden = NO;
[self playingStopAnimating];
}
}
}else if ([self.channelId isEqualToString:@"11"]) {
// 美食中国 历史记录
[self.view addSubview:self.historyBtn];
}
weakself
[CNLiveListManager shareListManager].scrollViewDidScrollBlock = ^(BOOL isUp) {
!weakSelf.scrollViewDidScrollBlock ?: weakSelf.scrollViewDidScrollBlock(isUp);
};
}else{
[self.view addSubview:self.navigationBar];
self.bgImgView.top = 0;
self.listContainerView.scrollView.scrollEnabled = YES;
}
// Do any additional setup after loading the view.
}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
if (self.showType == CNLiveSubVCShowtypeChannel) {
self.myCategoryView.top = kNavigationBarHeight;
}else{
self.searchBtn.right = KScreenWidth-12;
self.myCategoryView.top = 0;
CGFloat width = self.searchBtn.left;
self.searchBtn.centerY = self.myCategoryView.height/2;
if ([self.channelId isEqualToString:@"219"]) {
self.moreBtn.right = self.searchBtn.left-15;
self.moreBtn.centerY = self.myCategoryView.height/2;
self.progressView.right = self.moreBtn.left-15;
self.progressView.centerY = self.myCategoryView.height/2;
width = self.progressView.left;
}else if ([self.channelId isEqualToString:@"11"]){
self.historyBtn.right = self.searchBtn.left - 15;
self.historyBtn.centerY = self.myCategoryView.height/2;
width = self.historyBtn.left;
}
self.myCategoryView.width = width-10;
}
self.listContainerView.frame = CGRectMake(0, self.myCategoryView.bottom+10, kScreenWidth, self.view.bounds.size.height - self.myCategoryView.bottom -10);
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
#pragma mark - Notification
- (void)updatePlayingStatus:(NSNotification *)notifi {
NSInteger status = [[notifi.userInfo objectForKey:@"Status"] integerValue];//1播放 0暂停
if (status == 1) {
self.playTipImgV.hidden = YES;
[self playingStartAnimating];
}else {
self.playTipImgV.hidden = NO;
[self playingStopAnimating];
}
}
- (void)updatePlayingSchedule:(NSNotification *)notifi {
NSDictionary *dic = notifi.userInfo;
[self.progressView animationWithProgres:[[dic objectForKey:@"schedule"] floatValue] duration:0.8];
}
// 通知方法 更新当前播放音乐完成时的进度
- (void)audioPlayFinishedUpdateSchedule:(NSNotification *)notifi {
[self.progressView animationWithProgres:0.0f duration:0.0f];
}
// 通知方法 切换音乐时的显示
- (void)audioPlayUpdateInfo:(NSNotification *)notifi {
CNLiveAlbumAudioListModelModule *model = notifi.object;
if (model && !CNLiveStringIsEmpty(model.activityId)) {
self.playingBtn.userInteractionEnabled = YES;
self.progressView.hidden = NO;
} else {
self.playingBtn.userInteractionEnabled = NO;
self.progressView.hidden = YES;
}
if (model && (!CNLiveStringIsEmpty(model.img) || !CNLiveStringIsEmpty(model.poster) || !CNLiveStringIsEmpty(model.albumImg)) ) {
[self.playingImgV sd_setImageWithURL:[NSURL URLWithString:model.img?[model.img stringByRemovingPercentEncoding]:(model.poster?[model.poster stringByRemovingPercentEncoding]:[model.albumImg stringByRemovingPercentEncoding])] placeholderImage:[UIImage loadBundleImage:@""]];
} else {
self.playingImgV.image = nil;
}
}
#pragma mark - Method
// 开始当前播放音乐转动动画
- (void)playingStartAnimating {
CABasicAnimation *rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.fromValue = @0;
rotationAnimation.toValue = @(M_PI * 2);
rotationAnimation.duration = 5.0;
rotationAnimation.repeatCount = HUGE;
rotationAnimation.removedOnCompletion = NO;
[self.playingImgV.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
// 停止当前播放音乐转动动画
- (void)playingStopAnimating {
[self.playingImgV.layer removeAllAnimations];//停止动画
}
// 判断我的频道中是否包含参数中的一级频道中的二级频道(偏移前的判断)
- (NSInteger)containsWithChannelIndex:(NSInteger)index classifyId:(NSString *)classifyId {
NSString *normalKey = [NSString stringWithFormat:@"%@_%@",NormalChannelArray,CNUserShareModel.uid];
NSMutableArray *channelArray = [[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:normalKey]];
NSInteger i = 0;
if(channelArray.count > index){
NSString *modelStr = channelArray[index];
NSDictionary *dic = CNLiveStringJsonToDictionary(modelStr);
CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic];
for (CNCategoryGetChannelModel *subModel in model.pageStyleList) {
if ([subModel.id isEqualToString:classifyId]) {
return i;
}
if (CNLiveStringIsEmpty(subModel.pageType)) {
continue;
}else{
i++;
}
}
}
return -1;
}
-(void)handleDateWithChannelsArray{
[self.titles removeAllObjects];
NSMutableArray *array = [NSMutableArray array];
for (CNCategoryGetChannelModel *model in self.pageListArr) {
if (!CNLiveStringIsEmpty(model.showName) && !CNLiveStringIsEmpty(model.pageType)) {
[self.titles addObject:model.showName];
[array addObject:model];
if (!CNLiveStringIsEmpty(model.defaultPage) && [model.defaultPage isEqualToString:@"1"]) {
self.ld_currentIndex = [self.pageListArr indexOfObject:model];
}
}
}
self.pageListArr = array.copy;
}
// 一级频道显示隐藏时二级频道右侧的搜索按钮变宽变窄控制
- (void)rightSubViewWithShow:(BOOL)show {
if (show == self.listContainerView.scrollView.isScrollEnabled) {
return;
}
self.listContainerView.scrollView.scrollEnabled = show;
self.isHiddenFirst = show;
[self uploadUIWithIsUp:show];
}
-(void)uploadUIWithIsUp:(BOOL)isUp
{
if (!isUp) {
// 正常
self.searchBtn.width = 66;
self.searchBtn.right = KScreenWidth-12;
[self.searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
} else {
// 变窄
self.searchBtn.width = 30;
self.searchBtn.right = KScreenWidth-12;
[self.searchBtn setTitle:nil forState:UIControlStateNormal];
}
CGFloat width = self.searchBtn.left;
if ([self.channelId isEqualToString:@"219"]) {
self.moreBtn.right = self.searchBtn.left - 15;
self.progressView.right = self.moreBtn.left-15;
width = self.progressView.left;
} else if ([self.channelId isEqualToString:@"11"]) {
self.historyBtn.right = self.searchBtn.left - 15;;
width = self.historyBtn.left;
}
self.myCategoryView.width = width-10;
}
-(void)refreshCurrentVCData
{
weakself
[self.bgImgView sd_setImageWithURL:[NSURL URLWithString:self.backImageH5] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (image) {
if (self.showType == CNLiveSubVCShowtypeChannel) {
weakSelf.bgImgView.height = KScreenWidth*image.size.height/image.size.width + 50;
}else{
weakSelf.bgImgView.height = KScreenWidth*image.size.height/image.size.width;
}
}
}];
CNCategoryGetChannelModel *model = (CNCategoryGetChannelModel *)[self.pageListArr wjj_safetyObjectAtIndex:self.ld_currentIndex];
if (![CNUserShareManager isLogin]) {
[BHConfig set:ChannelsSelectSecond value:self.channelId];
}
NSDictionary *paramDic = nil;
if ([model.pageType isEqualToString:@"4"] || [model.pageType isEqualToString:@"5"]){
paramDic= @{
@"bgColor": model.backgroundColor?model.backgroundColor:@"",
@"backgroundImg": model.backgroundImg?model.backgroundImg:@"",
@"channelId":model.channelId?model.channelId:@"",
@"channelName":model.id?model.id:@"",
@"pageId":model.pageId?model.pageId:@"",
};
}
NSTimeInterval time = 300;
if ([model.id isEqualToString:@"1"]) {
time = 60;
}
NSDictionary *controllers = self.listContainerView.validListDict;
CNLiveListController *list = controllers[@(self.ld_currentIndex)];
[CNLiveClassifyJumpBridge listViewRefreshWithVC:list.childViewControllers[0] pageType:model.pageType.integerValue param:paramDic refreshTime:time];
}
-(void)showGuideView
{
if (![CNUserShareManager isLogin] || [BHConfig boolValue:wjjIsShowWitnessShadeKey]) {
return;
}
CNCategoryGetChannelModel *model = (CNCategoryGetChannelModel *)[self.pageListArr wjj_safetyObjectAtIndex:self.ld_currentIndex];
if (![[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowWitnessShadeKey,CNUserShareModelUid]]) {
[self showWitnessShadeViewWithModel:model];
} else if (![[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowSupervisionShadeKey,CNUserShareModelUid]]) {
[self showSupervisionViewWithModel:model];
}
if (![[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowSportShadeKey,CNUserShareModelUid]]) {
[self showSportShadeViewWithModel:model];
}
}
- (void)showWitnessShadeViewWithModel:(CNCategoryGetChannelModel *)model {
if (![CNUserShareManager isLogin]) {
return;
}
if (model && [model.id isEqualToString:@"101"]) {
UICollectionViewLayoutAttributes * att = [self.myCategoryView.collectionView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForRow:self.ld_currentIndex inSection:0]];
CGRect cellRect = att.frame;
CGRect cellFrame = [self.myCategoryView.collectionView convertRect:cellRect toView:AppKeyWindow];
if (self.delegate && [self.delegate respondsToSelector:@selector(showGuideShadeViewWithType:cellFrame:)]) {
[self.delegate showGuideShadeViewWithType:1 cellFrame:cellFrame];
}
}
}
// 显示目击者中监管首次显示引导图
- (void)showSupervisionViewWithModel:(CNCategoryGetChannelModel *)model {
if (![CNUserShareManager isLogin]) {
return;
}
if (model && [model.id isEqualToString:@"101"]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(showGuideShadeViewWithType:cellFrame:)]) {
[self.delegate showGuideShadeViewWithType:3 cellFrame:CGRectZero];
}
}
}
// 显示大众体育首次使用引导图
- (void)showSportShadeViewWithModel:(CNCategoryGetChannelModel *)model {
if (![CNUserShareManager isLogin]) {
return;
}
if (model && ([model.id isEqualToString:@"223"] || [model.id isEqualToString:@"801"])) {//大众体育
UICollectionViewLayoutAttributes * att = [self.myCategoryView.collectionView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForRow:self.ld_currentIndex inSection:0]];
CGRect cellRect = att.frame;
CGRect cellFrame = [self.myCategoryView.collectionView convertRect:cellRect toView:AppKeyWindow];
if (self.delegate && [self.delegate respondsToSelector:@selector(showGuideShadeViewWithType:cellFrame:)]) {
[self.delegate showGuideShadeViewWithType:2 cellFrame:cellFrame];
}
}
}
#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#pragma mark - TODO 正在播放
- (void)playingAction:(UIButton *)sender {
YYCache * yyCache = [YYCache cacheWithName:[NSString stringWithFormat:@"CNLastPlayedAudio_%@",CNUserShareModel.uid]];
CNLiveAlbumAudioListModelModule *model = (CNLiveAlbumAudioListModelModule *)[yyCache objectForKey:[NSString stringWithFormat:@"%@_%@",wjjLastAudioInfoSaveKey,CNUserShareModel.uid]];
if (model && model.activityId) {
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushAudioPlayerVC];
}
}
#pragma mark - TODO 历史
- (void)historyAction:(UIButton *)sender {
if (![CNUserShareManager isLogin]) {
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushLoginVC];
return;
}
if ([self.channelId isEqualToString:@"11"]){
//美食中国历史
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushHistoryVC];
}else if ([self.channelId isEqualToString:@"219"]) {
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushRecordVC];
}
}
#pragma mark - TODO 下载中...
- (void)loadingAction:(UIButton *)sender {
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushDownloadVC];
}
#pragma mark - TODO 搜索
- (void)searchAction:(UIButton *)sender {
// [MobClick event:@"channel_click_search"];
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushSearchVC];
}
#pragma mark - TODO 听见中国-更多
- (void)moreAction:(UIButton *)sender event:(UIEvent *)event{
if (![CNUserShareManager isLogin]) {
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushLoginVC];
return;
}
[CNLiveClassifyJumpBridge popOverShowEvent:event imageDone:^(NSInteger selectIndex) {
if (selectIndex == 0) {
// 下载中
[self loadingAction:self.downloadingBtn];
} else if (selectIndex == 1) {
// 历史记录
[self historyAction:self.historyBtn];
} else if (selectIndex == 2) {
// 我的设备
#pragma mark - TODO:皮肤测试
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushAddDiviceVC];
}
} dismissBlock:^{
NSLog(@"dismiss");
}];
}
#pragma mark - Public
-(JXCategoryTitleView *)preferredCategoryView{
return [[JXCategoryTitleView alloc] init];
}
-(CGFloat)preferredCategoryViewHeight
{
return 40;
}
#pragma mark - JXCategoryListContainerViewDelegate
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
CNCategoryGetChannelModel *model = self.pageListArr[index];
return [[CNLiveListController alloc] initWithModel:model black:_isBlack bgImage:self.backImage bgColor:self.backgroundColor bgImageH5:self.backImageH5];
}
#pragma mark - JXCategoryListContentViewDelegate
-(UIView *)listView
{
return self.view;
}
#pragma mark - JXCategoryViewDelegate
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index
{
self.navigationController.interactivePopGestureRecognizer.enabled = (index ==0);
self.ld_currentIndex = index;
if (index != self.myCategoryView.selectedIndex) {
[[NSNotificationCenter defaultCenter] postNotificationName:WjjH5StopVideoPlayerNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kDSHappinessPageControlScrollEnableNotification object:@(YES)];
}
CNCategoryGetChannelModel *model = (CNCategoryGetChannelModel *)[self.pageListArr wjj_safetyObjectAtIndex:index];
if (![CNUserShareManager isLogin]) {
[BHConfig set:ChannelsSelectSecond value:model.id];
}
NSDictionary *paramDic = nil;
if ([model.pageType isEqualToString:@"4"] || [model.pageType isEqualToString:@"5"]){
paramDic= @{
@"bgColor": model.backgroundColor?model.backgroundColor:@"",
@"backgroundImg": model.backgroundImg?model.backgroundImg:@"",
@"channelId":model.channelId?model.channelId:@"",
@"channelName":model.id?model.id:@"",
@"pageId":model.pageId?model.pageId:@"",
@"isHiddenFirst":@(self.isHiddenFirst)
};
}else{
paramDic= @{
@"isHiddenFirst":@(self.isHiddenFirst)
};
}
NSTimeInterval time = 300;
if ([model.id isEqualToString:@"1"]) {
time = 60;
}
NSDictionary *controllers = self.listContainerView.validListDict;
CNLiveListController *list = controllers[@(self.ld_currentIndex)];
[CNLiveClassifyJumpBridge listViewRefreshWithVC:list.childViewControllers[0] pageType:model.pageType.integerValue param:paramDic refreshTime:time];
[self showGuideView];
weakself
[self.bgImgView sd_setImageWithURL:[NSURL URLWithString:self.backImageH5] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (image) {
if (self.showType == CNLiveSubVCShowtypeChannel) {
weakSelf.bgImgView.height = KScreenWidth*image.size.height/image.size.width + 50;
}else{
weakSelf.bgImgView.height = KScreenWidth*image.size.height/image.size.width;
}
}
}];
}
#pragma mark - Getting&&Setting
-(JXCategoryTitleView *)myCategoryView
{
return (JXCategoryTitleView *)self.categoryView;
}
- (UIImageView *)bgImgView {
if (!_bgImgView) {
_bgImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 50, KScreenWidth, self.view.height/2-50)];
_bgImgView.backgroundColor = kWhiteColor;
}
return _bgImgView;
}
- (UIButton *)historyBtn {
if (!_historyBtn) {
_historyBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 19, 19)];
[_historyBtn setBackgroundImage:[UIImage loadBundleImage:@"listen_historey"] forState:UIControlStateNormal];
[_historyBtn addTarget:self action:@selector(historyAction:) forControlEvents:UIControlEventTouchUpInside];
_historyBtn.touchAreaInsets = UIEdgeInsetsMake(9, 9, 9, 9);
}
return _historyBtn;
}
- (UIButton *)downloadingBtn {
if (!_downloadingBtn) {
_downloadingBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 21, 19)];
[_downloadingBtn setBackgroundImage:[UIImage loadBundleImage:@"listen_historey"] forState:UIControlStateNormal];
[_downloadingBtn addTarget:self action:@selector(loadingAction:) forControlEvents:UIControlEventTouchUpInside];
_downloadingBtn.touchAreaInsets = UIEdgeInsetsMake(9, 9, 9, 9);
}
return _downloadingBtn;
}
- (CNAudioPlayProgressView *)progressView {
if (!_progressView) {
_progressView = [[CNAudioPlayProgressView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
_progressView.backgroundColor = CNLiveColorWithHexString(@"#5CBFB1");
_progressView.layer.cornerRadius = 20;
_progressView.layer.masksToBounds = YES;
_progressView.hidden = YES;
}
return _progressView;
}
- (UIButton *)playingBtn {
if (!_playingBtn) {
_playingBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
[_playingBtn addTarget:self action:@selector(playingAction:) forControlEvents:UIControlEventTouchUpInside];
_playingBtn.userInteractionEnabled = NO;
}
return _playingBtn;
}
- (UIImageView *)playingImgV {
if (!_playingImgV) {
_playingImgV = [[UIImageView alloc]initWithFrame:CGRectMake(2, 2, 36, 36)];
_playingImgV.image = [UIImage loadBundleImage:@""];
_playingImgV.backgroundColor = RGBA(255, 169, 82, 1);
_playingImgV.layer.cornerRadius = 18;
_playingImgV.layer.masksToBounds = YES;
}
return _playingImgV;
}
- (UIImageView *)playTipImgV {
if (!_playTipImgV) {
_playTipImgV = [[UIImageView alloc]initWithFrame:CGRectMake(13, 12, 10, 12)];
_playTipImgV.image = [UIImage loadBundleImage:@"playBtn"];
}
return _playTipImgV;
}
- (QMUIButton *)searchBtn {
if (!_searchBtn) {
_searchBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
_searchBtn.frame = CGRectMake(0, 0, 66, 30);
[_searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
_searchBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
if (self.isBlack) {
_searchBtn.backgroundColor = RGBA(245, 245, 245, 0.3);
[_searchBtn setTitleColor:KGray153Color forState:UIControlStateNormal];
[_searchBtn setImage:[UIImage loadBundleImage:@"ClassifySearchBlack"] forState:UIControlStateNormal];
}else
{
_searchBtn.backgroundColor = RGBA(249, 249, 249, 0.14);
[_searchBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
[_searchBtn setImage:[UIImage loadBundleImage:@"ClassifySearch"] forState:UIControlStateNormal];
}
_searchBtn.imagePosition = QMUIButtonImagePositionLeft;
_searchBtn.spacingBetweenImageAndTitle = 5;
_searchBtn.layer.cornerRadius = 15;
_searchBtn.layer.masksToBounds = YES;
[_searchBtn addTarget:self action:@selector(searchAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _searchBtn;
}
- (UIButton *)moreBtn {
if (!_moreBtn) {
_moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_moreBtn.frame = CGRectMake(0, 0, 18, 44);
[_moreBtn setImage:[UIImage loadBundleImage:@"ClassifyMore"] forState:UIControlStateNormal];
[_moreBtn addTarget:self action:@selector(moreAction:event:) forControlEvents:UIControlEventTouchUpInside];
_moreBtn.touchAreaInsets = UIEdgeInsetsMake(9, 9, 9, 9);
}
return _moreBtn;
}
#pragma mark - Navigation
- (CNLiveNavigationBar *)navigationBar {
if (!_navigationBar) {
_navigationBar = [CNLiveNavigationBar navigationBar];
_navigationBar.lineHidden = YES;
_navigationBar.backgroundColor = [UIColor clearColor];
_navigationBar.title.text = self.title;
_navigationBar.title.textColor = self.textColor;
if (!self.isBlack) {
_navigationBar.leftImage = [UIImage loadBundleImage:@"backWhite"];
}
weakself
_navigationBar.onClickLeftButton = ^{
strongself
[self.navigationController popViewControllerAnimated:YES];
};
}
return _navigationBar;
}
@end