CNLiveClassifySegmentController.m
46.9 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
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
//
// CNLiveClassifySegmentController.m
// CNLiveBaseClass
//
// Created by CNLive on 2021/8/7.
//
#import "CNLiveClassifySegmentController.h"
#import <UIKit/UIKit.h>
#import "CNCustomChannelListView.h"
#import "CNLiveListManager.h"
#import "CNLiveSubSegmentController.h"
#import "CNWebRedirectHandle.h"
#import "CNWitnessShadeManager.h"
#import "CNSupervisionGuideViewManager.h"
#import "CNLiveListController.h"
static const CGFloat animationTime = 0.3;
static const CGFloat animationHeight = 15;
@interface CNLiveClassifySegmentController ()<JXCategoryViewDelegate,CNCustomChannelListViewDelegate,CNSubClassifySegmentControllerDelegate>
@property (nonatomic, strong)JXCategoryTitleImageView *myCategoryView; //选择器
@property (nonatomic, strong) UIButton *customChannelsBtn;//频道按钮
@property (nonatomic, strong) UIButton *loginBtn;//登录按钮
@property (nonatomic, strong) CNCustomChannelListView *customChannelsV;//频道控制器窗口
@property (nonatomic, strong) UIView *fuzzyView;//游客登录弹框
@property (nonatomic, strong) UIImageView *topBgImg; //头部图片
@property (nonatomic, strong) UIImageView *indicatorImg;// 渐变图片
@property (nonatomic, assign) CGFloat topBgImgHeight;//头部图片高度
@property (nonatomic, strong) NSString * currentAtatusColor;
//电商通知返回
@property (nonatomic, copy) NSString *naviBackgroundColor;
@property (nonatomic, copy) NSString *naviNormalTitleColor;
@property (nonatomic, copy) NSString *naviSelectTitleColor;
@property (nonatomic, assign) NSUInteger statusState;
@property (nonatomic, strong) NSMutableArray *dataArray; //数据
@property (nonatomic, strong) NSMutableArray *bgImages; //背景图
@property (nonatomic, strong) NSMutableArray *bgColors; //背景色
@property (nonatomic, strong) NSMutableArray *imageNames; //选择器图片
@property (nonatomic, strong) NSMutableArray *imageTypes; //展示类型:图片/文字
@property (nonatomic, strong) NSMutableArray *statusBarColors; //状态栏颜色
@property (nonatomic, strong) NSMutableArray *textColors; //未选中字体颜色
@property (nonatomic, strong) NSMutableArray *textColorSeleteds; //选中字体颜色
@property (nonatomic, assign) BOOL hasChanged;
@property (nonatomic, assign) BOOL isEditing;
@property (nonatomic, assign) BOOL oldStatusBar;
@property (nonatomic, assign) BOOL isLoading;
@property (nonatomic, assign) BOOL isDSShopChanged;
@property (nonatomic, assign) BOOL contentLogin;//从内容跳过来的
@end
@implementation CNLiveClassifySegmentController
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(DSShopNavColorChange:) name:CNWjjDSShopNavColorChangeNotifiName object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PageControlScrollEnable:) name:kDSHappinessPageControlScrollEnableNotification object:nil];
self.navigationController.navigationBar.barTintColor = kWhiteColor;
[CNWebRedirectHandle manager].isSelectedClassify = YES;
[BHConfig set:CNLiveLaunchWithFirsh boolValue:NO];
self.topBgImgHeight = kStatusHeight+100;
self.ld_currentIndex = 0;
self.isLoginIndex = -1;
[self.view addSubview:self.topBgImg];
[self.view sendSubviewToBack:self.topBgImg];
[self.view addSubview:self.indicatorImg];
[self.view insertSubview:self.indicatorImg belowSubview:self.topBgImg];
[self dataDivideIntoNormalAndOtherWithFirst:YES];
[self handleDateWithChannelsArray];
self.myCategoryView.translatesAutoresizingMaskIntoConstraints = NO;
self.myCategoryView.titleColorGradientEnabled = YES;
self.myCategoryView.contentEdgeInsetLeft = 10;
self.myCategoryView.titleFont = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
self.myCategoryView.imageZoomEnabled = YES;
self.myCategoryView.imageZoomScale = 1.3;
self.myCategoryView.selectedAnimationEnabled = YES;
self.myCategoryView.titleLabelZoomEnabled = YES;
self.myCategoryView.titleLabelZoomScale = 1.4;
self.myCategoryView.cellWidthZoomEnabled = YES;
self.myCategoryView.cellWidthZoomScale = 1.3;
self.myCategoryView.imageSize = CGSizeMake(56, 18);
if (![CNUserShareManager isLogin]) {
NSString *showGuide = [[NSUserDefaults standardUserDefaults] objectForKey:CNLiveNetAddShowGuideKey];
if ([showGuide isEqualToString:@"1"] && ![BHConfig boolValue:ChannelsShowGuide]) {
NSString *showGuideH = [[NSUserDefaults standardUserDefaults] objectForKey:CNLiveNetAddShowGuideHKey];
BOOL result = [self judgeShowGuide:showGuideH];
if (!result) {
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpShowLoginView];
}
} else {
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpShowLoginView];
}
}
if (![CNUserShareManager isLogin]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
NSString *channelId = [BHConfig get:ChannelsSelectFirst];
[BHConfig set:ChannelsSelectFirst value:@""];
NSInteger selectChannelId = -1;
if (!CNLiveStringIsEmpty(channelId)) {
selectChannelId = [self containsWithChannelId:channelId];
if (selectChannelId != -1) {
self.ld_currentIndex = selectChannelId;
self.isLoginIndex = selectChannelId;
}
}
if ([CNWebRedirectHandle manager].isClickedIntegral) {
self.ld_currentIndex = [CNWebRedirectHandle manager].channelId;
[CNWebRedirectHandle manager].channelId = 0;
} else {
if (!CNLiveStringIsEmpty(channelId)) {
self.contentLogin = YES;
if(selectChannelId == -1){
//我的频道中没有这个频道
self.fuzzyView = [CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpShowFuzzyView];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(touristsLoginTipsViewIsClassify:) name:TouristloginTipsViewActionNotification object:nil];
}
}
//最后判断是否有url//
NSString *url = [BHConfig get:LoginPrepositionUrl];
if(url && ![url isEqualToString:@""]){
if ([url isEqualToString:@"DSShopLoginUrl"]) {
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushShopSDKVC];
}
else if ([url isEqualToString:@"judgeGiftUrl"]) {
NSURL *otherUrl = [BHConfig get:ActivityNewUrl];
if (otherUrl&&![otherUrl isEqual:[NSURL URLWithString:@""]] && [CNUserShareManager isLogin]) {
[CNLiveClassifyJumpBridge checkForloginTurnToWithURL:otherUrl];
}
}
else {
[CNLiveClassifyJumpBridge checkWithFunctionForShareURL:url];
}
} else {
if ([CNUserShareManager isLogin]) {
NSURL *otherUrl = [BHConfig get:ActivityNewUrl];
if (otherUrl &&![otherUrl isEqual:[NSURL URLWithString:@""]]) {
[CNLiveClassifyJumpBridge checkForloginTurnToWithURL:otherUrl];
}
}
}
}
self.categoryView.defaultSelectedIndex = self.ld_currentIndex;
if (!self.isLoading) {
[self uploadSubViews];
}
if ([CNUserShareManager isLogin]) {
[self.view addSubview:self.customChannelsBtn];
}else
{
[self.view addSubview:self.loginBtn];
}
weakself
[CNLiveListManager shareListManager].scrollViewDidScrollBlock = ^(BOOL isUp) {
[weakSelf scrollViewUpDowm:isUp];
};
self.listContainerView.frame = CGRectMake(0, self.myCategoryView.bottom, kScreenWidth, self.view.bounds.size.height - self.myCategoryView.bottom+ 50);
if ([CNUserShareManager isLogin]) {
self.myCategoryView.width = kScreenWidth - 45;
self.customChannelsBtn.centerY = [self preferredCategoryViewHeight]/2 + kStatusHeight;
self.customChannelsBtn.right = kScreenWidth - 18;
}else
{
self.myCategoryView.width = kScreenWidth - 70;
self.loginBtn.centerY = [self preferredCategoryViewHeight]/2 + kStatusHeight;
self.loginBtn.right = kScreenWidth - 11;
}
if (self.isHiddenFirst) {
self.myCategoryView.top = -50-kStatusHeight;
self.listContainerView.top = kStatusHeight;
if ([CNUserShareManager isLogin]) {
self.customChannelsBtn.centerY = self.myCategoryView.centerY + kStatusHeight;
}else
{
self.loginBtn.centerY = self.myCategoryView.centerY+kStatusHeight;
}
}
// Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (![[NSUserDefaults standardUserDefaults] boolForKey:CNLiveLaunchWithFirsh]) {
[[NSNotificationCenter defaultCenter] postNotificationName:kCNLiveDeepLinkPushNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kCNLiveRemotePushNotification object:nil];
}
self.navigationController.navigationBarHidden = YES;
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:CNLiveLaunchWithFirsh];
[[NSUserDefaults standardUserDefaults] synchronize];
self.tabBarController.tabBar.hidden = NO;
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if ([[NSUserDefaults standardUserDefaults] boolForKey:CNLiveLaunchWithFirsh] && ![BHConfig get:CNLiveLaunchWithFirsh]) {
[[NSNotificationCenter defaultCenter] postNotificationName:kCNLiveDeepLinkPushNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kCNLiveRemotePushNotification object:nil];
}
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self quitCustomChannels];
self.navigationController.navigationBarHidden = NO;
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
NSLog(@"CNClassifySegmentController dealloc");
}
-(UIStatusBarStyle)preferredStatusBarStyle
{
if (self.currentAtatusColor.intValue == 0) {
self.customChannelsBtn.selected = YES;
return UIStatusBarStyleLightContent;
}else
{
self.customChannelsBtn.selected = NO;
return UIStatusBarStyleDefault;
}
}
- (void)uploadSubViews
{
if (self.ld_currentIndex>=self.titles.count) {
self.ld_currentIndex = 0;
}
for (int i = 0;i<self.imageNames.count;i++) {
NSURL *url = [NSURL URLWithString:self.imageNames[i]];
[self.imageNames replaceObjectAtIndex:i withObject:url];
}
//分类控制器基础配置
self.myCategoryView.titles = self.titles;
self.myCategoryView.imageURLs = self.imageNames;
self.myCategoryView.loadImageCallback = ^(UIImageView *imageView, NSURL *imageURL) {
[imageView sd_setImageWithURL:imageURL];
};
[self updateSelectColors:self.ld_currentIndex];
[self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:self.ld_currentIndex unselectIndex:self.ld_currentIndex];
self.isLoad = YES;
if (![CNUserShareManager isLogin]) {
[CNLiveClassifyJumpBridge bringCenterLoginViewToFront];
}
}
#pragma mark - 通知的监听方法 Notification
// 分类接口请求成功或者失败
- (void)classifyChannelsRequest:(NSNotification *)noti {
[QMUITips hideAllTipsInView:self.view];
[self dataDivideIntoNormalAndOtherWithFirst:NO];
[self handleDateWithChannelsArray];
[self uploadSubViews];
}
// 分类接口数据请求完毕隐藏loading
- (void)classifyChannelsRequestedHideLoading:(NSNotification *)noti {
[QMUITips hideAllTipsInView:self.view];
}
// 电商中国通过电商SDK发通知修改电商频道的选择器样式
- (void)DSShopNavColorChange:(NSNotification *)noti {
self.naviBackgroundColor = [noti.userInfo objectForKey:@"naviBackgroundColor"];
self.naviNormalTitleColor = [noti.userInfo objectForKey:@"naviNormalTitleColor"];
self.naviSelectTitleColor = [noti.userInfo objectForKey:@"naviSelectTitleColor"];
self.statusState = [[noti.userInfo objectForKey:@"statusState"] integerValue];
if (CNLiveStringIsEmpty(self.naviBackgroundColor)||CNLiveStringIsEmpty(self.naviNormalTitleColor)||CNLiveStringIsEmpty(self.naviSelectTitleColor)) {
return;
}
// 判断是否是电商中国
NSInteger selectedIndex = self.myCategoryView.selectedIndex>=self.dataArray.count?0:self.myCategoryView.selectedIndex;
NSString *dataStr = [self.dataArray wjj_safetyObjectAtIndex:selectedIndex];
NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithDictionary:CNLiveStringJsonToDictionary(dataStr)];
if ([[dataDic objectForKey:@"pageType"] integerValue] != 2) {//电商中国
return;
}
// 改变电商中国channels UI
self.myCategoryView.titleColor = CNLiveColorWithHexString(self.naviNormalTitleColor);
self.myCategoryView.titleSelectedColor = CNLiveColorWithHexString(self.naviSelectTitleColor);
self.topBgImg.backgroundColor = CNLiveColorWithHexString(self.naviBackgroundColor);
self.currentAtatusColor = [NSString stringWithFormat:@"%lu",(unsigned long)self.statusState];
[self setNeedsStatusBarAppearanceUpdate];
// 改变数据
[self.textColors replaceObjectAtIndex:selectedIndex withObject:CNLiveColorWithHexString(self.naviNormalTitleColor)];
[self.textColorSeleteds replaceObjectAtIndex:selectedIndex withObject:CNLiveColorWithHexString(self.naviSelectTitleColor)];
[self.statusBarColors replaceObjectAtIndex:selectedIndex withObject:self.statusState==0 ? @"0" : @"1"];
[self.bgColors replaceObjectAtIndex:selectedIndex withObject:self.naviBackgroundColor];
self.isDSShopChanged = YES; //改变过
}
// 电商中国可以下拉出地图页面 当下拉出地图页面时不可以左右滚动
- (void)PageControlScrollEnable:(NSNotification *)noti {
if (!self.listContainerView.scrollView.isScrollEnabled) {
return;
}
BOOL scrollEnable = [noti.object boolValue];
NSLog(@"是否可滚动:%d",scrollEnable);
self.listContainerView.scrollView.scrollEnabled = scrollEnable;
}
- (void)touristsLoginTipsViewIsClassify:(NSNotification *)noti{
NSString *isClassify = noti.userInfo[@"isClassify"];
if([isClassify isEqualToString:@"close"]){
//隐藏TouristsLoginTipsView
[self.fuzzyView removeFromSuperview];
}else if([isClassify isEqualToString:@"jump"]){
//进入频道管理页面
[self.fuzzyView removeFromSuperview];
[self customAction:self.customChannelsBtn];
}
[[NSNotificationCenter defaultCenter] removeObserver:self name:TouristloginTipsViewActionNotification object:nil];
}
#pragma mark - Action
// 点击定制频道按钮进入定制
- (void)customAction:(UIButton *)sender {
[[NSNotificationCenter defaultCenter] postNotificationName:WjjH5StopVideoPlayerNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kDSHappinessPageControlScrollEnableNotification object:@(YES)];
self.hasChanged = NO;
self.isEditing = YES;
if (self.currentAtatusColor.intValue == 0) {
self.oldStatusBar = YES;
self.currentAtatusColor = @"1";
[self setNeedsStatusBarAppearanceUpdate];
} else {
self.oldStatusBar = NO;
}
[self.view addSubview:self.customChannelsV];
[UIView animateWithDuration:animationTime animations:^{
self.customChannelsV.alpha = 1.0;
self.customChannelsV.y = 0;
}];
}
// 登录
- (void)loginAction:(UIButton *)sender {
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushLoginVC];
}
#pragma mark - Method
- (NSInteger)containsWithChannelId:(NSString *)channelId {
NSString *normalKey = [NSString stringWithFormat:@"%@_%@",NormalChannelArray,CNUserShareModel.uid];
NSMutableArray *channelArray = [[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:normalKey]];
NSInteger i = 0;
for (NSString *str in channelArray) {
NSDictionary *dic = CNLiveStringJsonToDictionary(str);
CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic];
if ([model.id isEqualToString:channelId]) {
return i;
}
i++;
}
return -1;
}
- (BOOL)judgeShowGuide:(NSString *)guide {
if (CNLiveStringIsEmpty(guide)) {
return NO;;
}
NSString *locaVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
if ([locaVersion compare:guide options:NSNumericSearch]==NSOrderedAscending) {
//show
[BHConfig set:ChannelsShowGuide boolValue:YES];
NSDictionary *paramDic = @{
@"guide":guide
};
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpShowGuideView pageType:0 param:paramDic];
return YES;
} else {
return NO;
}
}
-(void)updateSelectColors:(NSInteger)index
{
self.ld_currentIndex = index;
NSString *backgroundImage = [self.bgImages wjj_safetyObjectAtIndex:index];
weakself
[self.topBgImg sd_setImageWithURL:[NSURL URLWithString:backgroundImage] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (image) {
weakSelf.topBgImgHeight = KScreenWidth*image.size.height/image.size.width;
} else {
weakSelf.topBgImgHeight = kStatusHeight+100;
}
if (weakSelf.topBgImgHeight<kStatusHeight+100) {
weakSelf.topBgImgHeight = kStatusHeight+100;
}
weakSelf.topBgImg.height = weakSelf.topBgImgHeight;
weakSelf.topBgImg.bottom = kStatusHeight+100;
}];
NSString *backgroundColor = [self.bgColors wjj_safetyObjectAtIndex:index];
self.topBgImg.backgroundColor = CNLiveColorWithHexString(backgroundColor);
self.indicatorImg.alpha = 0;
self.topBgImg.alpha = 1;
self.myCategoryView.titleColor = self.textColors[index];
self.myCategoryView.titleSelectedColor = self.textColorSeleteds[index];
if (!self.currentAtatusColor || ![self.currentAtatusColor isEqualToString:self.statusBarColors[index]] ) {
self.currentAtatusColor = self.statusBarColors[index];
[self setNeedsStatusBarAppearanceUpdate];
}
}
//配置选中状态显示图片,未选中展示文字
- (void)configCategoryViewWithType:(JXCategoryTitleImageType)imageType selectIndex:(NSInteger)index unselectIndex:(NSInteger)unIndex
{
NSString *backgroundImage = [self.bgImages wjj_safetyObjectAtIndex:index];
weakself
[self.topBgImg sd_setImageWithURL:[NSURL URLWithString:backgroundImage] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (image) {
weakSelf.topBgImgHeight = KScreenWidth*image.size.height/image.size.width;
} else {
weakSelf.topBgImgHeight = kStatusHeight+100;
}
if (weakSelf.topBgImgHeight<kStatusHeight+100) {
weakSelf.topBgImgHeight = kStatusHeight+100;
}
weakSelf.topBgImg.height = weakSelf.topBgImgHeight;
weakSelf.topBgImg.bottom = kStatusHeight+100;
}];
NSString *backgroundColor = [self.bgColors wjj_safetyObjectAtIndex:index];
self.topBgImg.backgroundColor = CNLiveColorWithHexString(backgroundColor);
NSString *unBackgroundImage = [self.bgImages wjj_safetyObjectAtIndex:unIndex];
[self.indicatorImg sd_setImageWithURL:[NSURL URLWithString:unBackgroundImage] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (image) {
weakSelf.topBgImgHeight = KScreenWidth*image.size.height/image.size.width;
} else {
weakSelf.topBgImgHeight = kStatusHeight+100;
}
if (weakSelf.topBgImgHeight<kStatusHeight+100) {
weakSelf.topBgImgHeight = kStatusHeight+100;
}
weakSelf.indicatorImg.height = weakSelf.topBgImgHeight;
weakSelf.indicatorImg.bottom = kStatusHeight+100;
}];
NSString *unBackgroundColor = [self.bgColors wjj_safetyObjectAtIndex:unIndex];
self.indicatorImg.backgroundColor = CNLiveColorWithHexString(unBackgroundColor);
NSMutableArray *types = [NSMutableArray array];
for (int i = 0; i < self.titles.count; i ++) {
if (i == index || i == unIndex) {
NSURL *url = self.imageNames[i];
NSString *str = [url absoluteString];
if ([str isEqual:@""]) {
[types addObject:@(JXCategoryTitleImageType_OnlyTitle)];
}else{
[types addObject:@(imageType)];
}
}else{
[types addObject:@(JXCategoryTitleImageType_OnlyTitle)];
}
}
self.myCategoryView.imageTypes = types;
for (int i = 0; i < self.titles.count; i ++) {
[self.myCategoryView reloadCellAtIndex:i];
}
}
- (void)dataDivideIntoNormalAndOtherWithFirst:(BOOL)first {
NSArray *channelsArray = [[NSUserDefaults standardUserDefaults] objectForKey:CNLiveNetAddGetCategoryChannels];
NSString *normalKey = [NSString stringWithFormat:@"%@_%@",NormalChannelArray,CNUserShareModel.uid];
NSString *otherKey = [NSString stringWithFormat:@"%@_%@",OtherChannelArray,CNUserShareModel.uid];
NSMutableArray *normalArray = [[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:normalKey]];
NSMutableArray *otherArray = [[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:otherKey]];
// 请求到过数据
if ([NSArray isArray:channelsArray]) {
NSString *newChannelVer = [[NSUserDefaults standardUserDefaults] objectForKey:CNWjjNewCategoryChannelVerKey];
NSString *oldChannelVer = [[NSUserDefaults standardUserDefaults] objectForKey:CNWjjOldCategoryChannelVerKey];
if (CNLiveStringIsEmpty(newChannelVer) || CNLiveStringIsEmpty(oldChannelVer) || [newChannelVer isEqualToString:oldChannelVer]) {// 没有新版本
NSMutableArray *tempAllArray = [[NSMutableArray alloc] initWithArray:channelsArray]; //临时总频道
NSMutableArray *tempOtherArray = [NSMutableArray array];//临时其他频道
NSMutableArray *tempNormalArray = [NSMutableArray array];//临时我的频道
if ([NSArray isArray:otherArray]) {//"其他频道"有数据
// 比较数据并存储
for (NSString *str in otherArray) {//遍历其他频道
NSDictionary *dic = CNLiveStringJsonToDictionary(str);
CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic];
NSInteger index = [model containsWithChannelArray:tempAllArray];
if (index==-1) {
continue;
}
[tempOtherArray addObject:[tempAllArray wjj_safetyObjectAtIndex:index]];
if (index<tempAllArray.count) {
[tempAllArray removeObjectAtIndex:index];
}
}
[otherArray removeAllObjects];
otherArray = tempOtherArray; //新"其他频道"
}
for (NSString *str in normalArray) { //对"我的频道"按本地顺序排序
NSDictionary *dic = CNLiveStringJsonToDictionary(str);
CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic];
NSInteger index = [model containsWithChannelArray:tempAllArray];
if (index==-1) {
continue;
}
[tempNormalArray addObject:[tempAllArray wjj_safetyObjectAtIndex:index]];
if (index<tempAllArray.count) {
[tempAllArray removeObjectAtIndex:index];
}
}
[tempNormalArray addObjectsFromArray:tempAllArray];
[normalArray removeAllObjects];
normalArray = tempNormalArray;
} else {
// 有新版本
normalArray = channelsArray.mutableCopy;
[otherArray removeAllObjects];
}
[[NSUserDefaults standardUserDefaults] setObject:newChannelVer forKey:CNWjjOldCategoryChannelVerKey];
} else { // 从未请求到过数据
if ([BHConfig boolValue:ChannelsRequested]&& first) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(classifyChannelsRequest:) name:CNWjjClassifyChannelsRequestStateNotifiName object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(classifyChannelsRequestedHideLoading:) name:CNWjjClassifyChannelsRequestHideLoadingNotifiName object:nil];
[QMUITips showLoadingInView:self.view];
self.isLoading = YES;
return;
}
// 默认数据
NSMutableArray *defaultArray = [NSMutableArray array];
NSString *jsonName = [CNLiveEnvironmentManager manager].isTestEnvironment?@"wjjCategoryH5Test":@"wjjCategoryH5";
NSString *path = [[NSBundle mainBundle] pathForResource:jsonName ofType:@"json"];
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
NSArray *dataArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
for (NSDictionary *dic in dataArray) {
[defaultArray addObject:CNLiveNSDictionaryDicToJson(dic)];
}
NSMutableArray *tempAllArray = [[NSMutableArray alloc] initWithArray:defaultArray];
NSMutableArray *tempOtherArray = [NSMutableArray array];
NSMutableArray *tempNormalArray = [NSMutableArray array];//临时我的频道
if ([NSArray isArray:otherArray]) {//其他频道有数据
// 比较数据并存储
for (NSString *str in otherArray) {
NSDictionary *dic = CNLiveStringJsonToDictionary(str);
CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic];
NSInteger index = [model containsWithChannelArray:tempAllArray];
if (index==-1) {
continue;
}
[tempOtherArray addObject:[tempAllArray wjj_safetyObjectAtIndex:index]];
if (index<tempAllArray.count) {
[tempAllArray removeObjectAtIndex:index];
}
}
[otherArray removeAllObjects];
otherArray = tempOtherArray;
}
for (NSString *str in normalArray) { //对"我的频道"按本地顺序排序
NSDictionary *dic = CNLiveStringJsonToDictionary(str);
CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic];
NSInteger index = [model containsWithChannelArray:tempAllArray];
if (index==-1) {
continue;
}
[tempNormalArray addObject:[tempAllArray wjj_safetyObjectAtIndex:index]];
if (index<tempAllArray.count) {
[tempAllArray removeObjectAtIndex:index];
}
}
[tempNormalArray addObjectsFromArray:tempAllArray];
[normalArray removeAllObjects];
normalArray = tempNormalArray;
[[NSUserDefaults standardUserDefaults] setObject:@"default" forKey:CNWjjOldCategoryChannelVerKey];
}
[[NSUserDefaults standardUserDefaults] setObject:normalArray forKey:normalKey];
[[NSUserDefaults standardUserDefaults] setObject:otherArray forKey:otherKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}
//解析数据
-(void)handleDateWithChannelsArray
{
NSString *normalKey = [NSString stringWithFormat:@"%@_%@",NormalChannelArray,CNUserShareModel.uid];
NSArray *normalArray = [[NSUserDefaults standardUserDefaults] objectForKey:normalKey];
[self.dataArray removeAllObjects];
[self.titles removeAllObjects];
[self.imageNames removeAllObjects];
[self.bgImages removeAllObjects];
[self.bgColors removeAllObjects];
[self.textColors removeAllObjects];
[self.textColorSeleteds removeAllObjects];
[self.statusBarColors removeAllObjects];
for (NSString *str in normalArray) {
NSDictionary *dic = CNLiveStringJsonToDictionary(str);
CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic];
[self.dataArray addObject:model];
[self.titles addObject:model.showName];
if (model.img) {
[self.imageNames addObject:model.img];
}else{
[self.imageNames addObject:@""];
}
if (!CNLiveStringIsEmpty(model.backgroundImg)) {
[self.bgImages addObject:model.backgroundImg];
} else {
[self.bgImages addObject:@""];
}
if (!CNLiveStringIsEmpty(model.backgroundColor)) {
[self.bgColors addObject:model.backgroundColor];
} else {
[self.bgColors addObject:@"#FFFFFF"];
}
if (!CNLiveStringIsEmpty(model.textColor)) {
[self.textColors addObject:CNLiveColorWithHexString(model.textColor)];
} else {
[self.textColors addObject:CNLiveColorWithHexString(@"#848494")];
}
if (!CNLiveStringIsEmpty(model.textColorSelected)) {
[self.textColorSeleteds addObject:CNLiveColorWithHexString(model.textColorSelected)];
} else {
[self.textColorSeleteds addObject:CNLiveColorWithHexString(@"#13CC0C")];
}
if (!CNLiveStringIsEmpty(model.statusBarColor)) {
[self.statusBarColors addObject:model.statusBarColor];
[self setNeedsStatusBarAppearanceUpdate];
}else
{
[self.statusBarColors addObject:@"1"];
}
if (!CNLiveStringIsEmpty(model.defaultPage) && [model.defaultPage isEqualToString:@"1"]) {
self.ld_currentIndex = [normalArray indexOfObject:dic];
}
if ([model.pageType isEqualToString:@"2"] && self.isDSShopChanged) {//是电商中国且刷新过颜色
NSInteger i = [normalArray indexOfObject:str];
[self.bgColors replaceObjectAtIndex:i withObject:self.naviBackgroundColor];
[self.statusBarColors replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%lu",(unsigned long)self.statusState]];
[self.textColors replaceObjectAtIndex:i withObject:CNLiveColorWithHexString(self.naviNormalTitleColor)];
[self.textColorSeleteds replaceObjectAtIndex:i withObject:CNLiveColorWithHexString(self.naviSelectTitleColor)];
}
}
}
-(void)scrollViewUpDowm:(BOOL)isUp
{
self.listContainerView.scrollView.scrollEnabled = !isUp;
self.isHiddenFirst = isUp;
NSDictionary *controllers = self.listContainerView.validListDict;
[UIView animateWithDuration:0.3 animations:^{
if (isUp) {
[self scrollViewUp];
}else
{
[self scrollViewDown];
}
CNLiveSubSegmentController *subVC = controllers[@(self.ld_currentIndex)];
if ([subVC isKindOfClass:[CNLiveSubSegmentController class]]) {
[subVC rightSubViewWithShow:isUp];
}
}];
}
-(void)scrollViewUp{
self.topBgImg.bottom = kStatusHeight+50;
self.myCategoryView.collectionView.top = -50-kStatusHeight;
self.listContainerView.top = kStatusHeight;
if ([CNUserShareManager isLogin]) {
self.customChannelsBtn.centerY = self.myCategoryView.collectionView.centerY + kStatusHeight;
}else
{
self.loginBtn.centerY = self.myCategoryView.collectionView.centerY+kStatusHeight;
}
}
-(void)scrollViewDown{
self.topBgImg.bottom = kStatusHeight+100;
self.myCategoryView.top = kStatusHeight;
self.myCategoryView.collectionView.top = 0;
self.listContainerView.top = self.myCategoryView.bottom;
if ([CNUserShareManager isLogin]) {
self.customChannelsBtn.centerY = self.myCategoryView.centerY;
}else
{
self.loginBtn.centerY = self.myCategoryView.centerY;
}
}
#pragma mark -
#pragma mark - CNSubClassifySegmentControllerDelegate
// 显示 目击者/监管/大众体育 首次使用引导页
- (void)showGuideShadeViewWithType:(NSInteger)type cellFrame:(CGRect)cellFrame {
if (type==1) {
[CNWitnessShadeManager showWitnessShadeViewWithTopImg:@"mjz" contentImg:@"mjz-new-text" topImgRect:CGRectMake(cellFrame.origin.x-10, cellFrame.origin.y+10, 75, 30) contentImgSize:CGSizeMake(199, 68) vc:self cancelBlock:^{
[BHConfig set:wjjIsShowWitnessShadeKey boolValue:nil];
if (![[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowSupervisionShadeKey,CNUserShareModelUid]]) {
[CNSupervisionGuideViewManager showSupervisionGuideViewWithVC:self];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowSupervisionShadeKey,CNUserShareModelUid]];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}];
[BHConfig set:wjjIsShowWitnessShadeKey boolValue:YES];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowWitnessShadeKey,CNUserShareModelUid]];
[[NSUserDefaults standardUserDefaults] synchronize];
} else if(type==2) {
[CNWitnessShadeManager showWitnessShadeViewWithTopImg:@"dzty" contentImg:@"dzty-text" topImgRect:CGRectMake(cellFrame.origin.x-10, cellFrame.origin.y+10, 102, 30) contentImgSize:CGSizeMake(276, 129) vc:self cancelBlock:nil];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowSportShadeKey,CNUserShareModelUid]];
[[NSUserDefaults standardUserDefaults] synchronize];
} else if (type==3) {
[CNSupervisionGuideViewManager showSupervisionGuideViewWithVC:self];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowSupervisionShadeKey,CNUserShareModelUid]];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
#pragma mark - CNCustomChannelListViewDelegate !!!!!!!!!!!!!!!!!!!!!!
- (void)changeChannelsList
{
// "完成"分类频道顺序重排
[self handleDateWithChannelsArray];
[self uploadSubViews];
[self.myCategoryView reloadData];
self.hasChanged = YES;
}
- (void)didSelectedCommonChannelWithIndex:(NSInteger)index
{
[self quitCustomChannels];
self.ld_currentIndex = index;
[self.myCategoryView selectItemAtIndex:index];
}
- (void)pushToControllerWithIndex:(NSInteger)index
{
// 跳到其他频道的对应页面
NSString *otherKey = [NSString stringWithFormat:@"%@_%@",OtherChannelArray,CNUserShareModel.uid];
NSArray *otherArray = [[NSUserDefaults standardUserDefaults] objectForKey:otherKey];
NSString *dataStr = [otherArray wjj_safetyObjectAtIndex:index];
NSDictionary *dic = CNLiveStringJsonToDictionary(dataStr);
CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic];
NSDictionary *paramDic = nil;
BOOL isBlack = NO;
if (CNLiveStringIsEmpty(model.statusBarColor)) {
isBlack = YES;
} else {
isBlack = [model.statusBarColor boolValue];//1 黑色
}
if (model.pageStyleList.count>0) {
CNLiveSubSegmentController *subVC = [[CNLiveSubSegmentController alloc] initWithModel:model];
subVC.showType = CNLiveSubVCShowtypeChannel;
subVC.isBlack = isBlack;
[[BaseAppDelegate sharedAppDelegate] pushViewController:subVC];
}else{
if([model.pageType isEqualToString:@"4"] || [model.pageType isEqualToString:@"5"]){
paramDic= @{
@"bgColor": model.backgroundColor?model.backgroundColor:@"",
@"channelId":model.channelId?model.channelId:@"",
@"channelName":model.id?model.id:@"",
@"pageId":model.pageId?model.pageId:@"",
};
}else if ([model.pageType isEqualToString:@"2"]) {//电商中国
paramDic = @{
@"showName":model.showName?model.showName:@""
};
}else
{
BOOL isBlack = NO;
if (CNLiveStringIsEmpty(model.statusBarColor)) {
isBlack = YES;
} else {
isBlack = [model.statusBarColor boolValue];//1 黑色
}
paramDic= @{
@"title": model.showName?model.showName:@"",
@"isBlack":@(isBlack),
@"thirdUrl":model.thirdUrl?model.thirdUrl:@""
};
}
[CNLiveClassifyJumpBridge showViewOrPushVCWithCurrentVC:self pushType:CNLiveClassifyJumpPushCustomVC pageType:model.pageType.integerValue param:paramDic];
}
}
- (void)closeCustomChannelsView {
// 关闭定制频道页
[self quitCustomChannels];
}
// 退出定制频道编辑页面
- (void)quitCustomChannels {
self.isEditing = NO;
if (self.oldStatusBar && !self.hasChanged) {
self.oldStatusBar = NO;
self.currentAtatusColor = @"0";
[self setNeedsStatusBarAppearanceUpdate];
}
self.hasChanged = NO;
[UIView animateWithDuration:animationTime animations:^{
self.customChannelsV.alpha = 0.0;
self.customChannelsV.y = animationHeight;
} completion:^(BOOL finished) {
[self.customChannelsV removeFromSuperview];
self.customChannelsV = nil;
}];
}
#pragma mark - JXCategoryListContainerViewDelegate
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
CNCategoryGetChannelModel *model = self.dataArray[index];
BOOL isBlack = NO;
if (CNLiveStringIsEmpty(model.statusBarColor)) {
isBlack = YES;
} else {
isBlack = [model.statusBarColor boolValue];//1 黑色
}
if (model.pageStyleList.count>0) {
self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight);
CNLiveSubSegmentController *subVC = [[CNLiveSubSegmentController alloc] initWithModel:model];
subVC.showType = CNLiveSubVCShowtypeClassify;
subVC.isBlack = isBlack;
subVC.delegate = self;
if (index == self.isLoginIndex) {
subVC.selectChannelId = index;
}
weakself
subVC.scrollViewDidScrollBlock = ^(BOOL isUp) {
[weakSelf scrollViewUpDowm:isUp];
};
return subVC;
}
self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight - 50);
return [[CNLiveListController alloc] initWithModel:model black:isBlack bgImage:self.bgImages[index] bgColor:model.backgroundColor bgImageH5:model.backgroundImgH5];
}
#pragma mark - JXCategoryViewDelegate
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
NSLog(@"%@", NSStringFromSelector(_cmd));
// 侧滑手势处理
self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
[self updateSelectColors:index];
[self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:index unselectIndex:index];
CNCategoryGetChannelModel *model = (CNCategoryGetChannelModel *)[self.dataArray wjj_safetyObjectAtIndex:index];
if (![CNUserShareManager isLogin]) {
[BHConfig set:ChannelsSelectFirst value:model.id];
}
if (model.pageStyleList.count>0) {
CNLiveSubSegmentController *subVC = (CNLiveSubSegmentController *)self.listContainerView.validListDict[@(index)];
subVC.showType = CNLiveSubVCShowtypeClassify;
if (subVC && [subVC respondsToSelector:@selector(refreshCurrentVCData)]) {
[subVC refreshCurrentVCData];
}
BOOL witness = ![[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowWitnessShadeKey,CNUserShareModelUid]];
BOOL sport = ![[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowSportShadeKey,CNUserShareModelUid]];
BOOL supervision = ![[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%@_%@",wjjIsShowSupervisionShadeKey,CNUserShareModelUid]];
if (!self.contentLogin && (witness || sport || supervision) && [CNUserShareManager isLogin]) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[subVC showGuideView];
});
}
self.contentLogin = NO;
}else{
NSDictionary *paramDic = nil;
if ([model.pageType isEqualToString:@"4"] || [model.pageType isEqualToString:@"5"]){
paramDic= @{
@"bgColor": model.backgroundColor?model.backgroundColor:@"",
@"backgroundImg": model.backgroundImgH5?model.backgroundImgH5:@"",
@"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];
}
if (index != self.myCategoryView.selectedIndex) {
[[NSNotificationCenter defaultCenter] postNotificationName:WjjH5StopVideoPlayerNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kDSHappinessPageControlScrollEnableNotification object:@(YES)];
}
// [MobClick event:@"channel_click_top"];
}
- (void)categoryView:(JXCategoryBaseView *)categoryView scrollingFromLeftIndex:(NSInteger)leftIndex toRightIndex:(NSInteger)rightIndex ratio:(CGFloat)ratio{
if (self.ld_currentIndex == leftIndex) {
[self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:leftIndex unselectIndex:rightIndex];
self.topBgImg.alpha = 1 - ratio;
self.indicatorImg.alpha = ratio;
}else{
[self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:rightIndex unselectIndex:leftIndex];
self.topBgImg.alpha = ratio;
self.indicatorImg.alpha = 1 - ratio;
}
}
#pragma mark - Public
-(JXCategoryBaseView *)preferredCategoryView
{
return [[JXCategoryTitleImageView alloc] init];
}
#pragma mark - Getting
-(JXCategoryTitleImageView *)myCategoryView
{
return (JXCategoryTitleImageView *)self.categoryView;
}
- (UIImageView *)topBgImg
{
if (!_topBgImg) {
_topBgImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, self.topBgImgHeight)];
_topBgImg.contentMode = UIViewContentModeScaleAspectFill;
}
return _topBgImg;
}
- (UIImageView *)indicatorImg
{
if (!_indicatorImg) {
_indicatorImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, self.topBgImgHeight)];
_indicatorImg.contentMode = UIViewContentModeScaleAspectFill;
_indicatorImg.alpha = 0;
}
return _indicatorImg;
}
- (UIButton *)customChannelsBtn {
if (!_customChannelsBtn) {
_customChannelsBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 19, 19)];
[_customChannelsBtn setImage:[UIImage loadBundleImage:@"ik_subtitle_more_black"] forState:UIControlStateNormal];
[_customChannelsBtn setImage:[UIImage loadBundleImage:@"ik_subtitle_more_white"] forState:UIControlStateSelected];
[_customChannelsBtn addTarget:self action:@selector(customAction:) forControlEvents:UIControlEventTouchUpInside];
_customChannelsBtn.touchAreaInsets = UIEdgeInsetsMake(20, 20, 20, 20);
}
return _customChannelsBtn;
}
- (CNCustomChannelListView *)customChannelsV {
if (!_customChannelsV) {
_customChannelsV = [[CNCustomChannelListView alloc] initWithFrame:CGRectMake(0, animationHeight, KScreenWidth, KScreenHeight)];
_customChannelsV.backgroundColor = kWhiteColor;
_customChannelsV.alpha = 0;
_customChannelsV.delegate = self;
}
return _customChannelsV;
}
- (UIButton *)loginBtn {
if (!_loginBtn) {
_loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_loginBtn.backgroundColor = RGBA(35, 212, 30, 1);
_loginBtn.frame = CGRectMake(0, 0, 52, 24);
_loginBtn.layer.cornerRadius = 12;
_loginBtn.layer.masksToBounds = YES;
[_loginBtn setTitle:@"登录" forState:UIControlStateNormal];
[_loginBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
_loginBtn.titleLabel.font = [UIFont systemFontOfSize:13];
[_loginBtn addTarget:self action:@selector(loginAction:) forControlEvents:UIControlEventTouchUpInside];
_loginBtn.touchAreaInsets = UIEdgeInsetsMake(8, 8, 8, 8);
}
return _loginBtn;
}
-(NSMutableArray *)imageNames
{
if (!_imageNames) {
_imageNames = [[NSMutableArray alloc] init];
}
return _imageNames;
}
- (NSMutableArray *)bgImages
{
if (!_bgImages) {
_bgImages = [[NSMutableArray alloc] init];
}
return _bgImages;
}
- (NSMutableArray *)bgColors
{
if (!_bgColors) {
_bgColors = [[NSMutableArray alloc] init];
}
return _bgColors;
}
-(NSMutableArray *)textColors
{
if (!_textColors) {
_textColors = [[NSMutableArray alloc] init];
}
return _textColors;
}
-(NSMutableArray *)textColorSeleteds
{
if (!_textColorSeleteds) {
_textColorSeleteds = [[NSMutableArray alloc] init];
}
return _textColorSeleteds;
}
-(NSMutableArray *)dataArray
{
if (!_dataArray) {
_dataArray = [[NSMutableArray alloc] init];
}
return _dataArray;
}
- (NSMutableArray *)statusBarColors
{
if (!_statusBarColors) {
_statusBarColors = [[NSMutableArray alloc] init];
}
return _statusBarColors;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end