Files
peko-ios/YuMi/Modules/YMNewHome/View/XPHomeRecommendViewController.m

580 lines
21 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// XPHomeRecommendViewController.m
// YuMi
//
// Created by YuMi on 2022/2/21.
//
#import "XPHomeRecommendViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <JXCategoryView/JXCategoryView.h>
#import <MJRefresh/MJRefresh.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "YUMIMacroUitls.h"
#import "DJDKMIMOMColor.h"
#import "XPWeakTimer.h"
#import "ClientConfig.h"
#import "UIImage+Utils.h"
#import "Api+Room.h"
#import "Api+RoomSetting.h"
#import "AccountInfoStorage.h"
#import "TTPopup.h"
#import "NSArray+Safe.h"
2023-09-07 19:01:31 +08:00
#import "CountDownHelper.h"
#import "XPSkillCardPlayerManager.h"
#import "UploadFile.h"
2023-07-14 18:50:55 +08:00
///View
#import "XPNewHomePlayTableViewCell.h"
#import "XPNewHomeRecommendTableViewCell.h"
#import "XPNewHomePlayEmptyTableViewCell.h"
#import "XPHomeBannerTableViewCell.h"
#import "XPNewHomePartyTableViewCell.h"
#import "XPRoomViewController.h"
#import "XPWebViewController.h"
2023-09-07 19:01:31 +08:00
#import "XPMineUserInfoViewController.h"
#import "SessionViewController.h"
2023-07-14 18:50:55 +08:00
///Model
#import "HomePlayRoomModel.h"
#import "HomeBannerInfoModel.h"
#import "HomeRecommendRoomModel.h"
#import "ClanDetailInfoModel.h"
///P
#import "XPNewHomeRecommendPresenter.h"
#import "XPNewHomeRecommendProtocol.h"
2023-09-21 17:44:59 +08:00
#import "XPHomeGameView.h"
2023-07-14 18:50:55 +08:00
UIKIT_EXTERN NSString * const kShieldingNotification;
2023-09-21 17:44:59 +08:00
@interface XPHomeRecommendViewController ()<UITableViewDelegate, UITableViewDataSource, XPNewHomePlayTableViewCellDelegate, XPHomeBannerTableViewCellDelegate,XPNewHomeRecommendTableViewCellDelegate,XPNewHomeRecommendProtocol,XPNewHomePartyTableViewCellDelegate,CountDownHelperDelegate,XPNewHomePlayEmptyTableViewCellDelegate,XPHomeGameViewDelegate>
2023-07-14 18:50:55 +08:00
///
@property (nonatomic,strong) UITableView *tableView;
2023-09-05 11:45:21 +08:00
2023-07-14 18:50:55 +08:00
///
2023-09-07 19:01:31 +08:00
@property (nonatomic,copy) NSArray<HomePlayRoomModel *> *playTeamList;
2023-07-14 18:50:55 +08:00
///
2023-09-07 19:01:31 +08:00
@property (nonatomic,strong) NSMutableArray<HomePlayRoomModel *> *personalRoomList;
2023-07-14 18:50:55 +08:00
///
@property (nonatomic,strong) RoomInfoModel * roomInfo;
///,
@property (nonatomic,assign) BOOL isRequestData;
2023-09-07 19:01:31 +08:00
///
@property (nonatomic,strong) CountDownHelper *countDownHelper;
///cell
@property(nonatomic,strong)XPNewHomePartyTableViewCell *cell;
///cellUITableViewY
@property(nonatomic,assign) CGFloat cellY;
2023-09-21 17:44:59 +08:00
///
@property (nonatomic, strong) NSMutableArray<LittleGameInfoModel *> *littleGameArray;
2023-07-14 18:50:55 +08:00
@end
@implementation XPHomeRecommendViewController
- (XPNewHomeRecommendPresenter *)createPresenter {
return [[XPNewHomeRecommendPresenter alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
2023-09-07 19:01:31 +08:00
2023-07-14 18:50:55 +08:00
}
2023-09-07 19:01:31 +08:00
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
self.countDownHelper.delegate = self;
2023-07-14 18:50:55 +08:00
}
2023-09-07 19:01:31 +08:00
-(void)viewDidDisappear:(BOOL)animated{
[super viewDidAppear:animated];
[self.countDownHelper stopCountDown];
self.countDownHelper.delegate = nil;
[[XPSkillCardPlayerManager shareInstance] stopMusic];
if(self.cell != nil){
[self.cell setPlaySoundStatus:NO];
self.cell = nil;
2023-07-14 18:50:55 +08:00
}
2023-09-07 19:01:31 +08:00
2023-07-14 18:50:55 +08:00
}
-(void)dealloc{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
#pragma mark - InitHttp
2023-09-07 19:01:31 +08:00
2023-07-14 18:50:55 +08:00
-(void)requestData{
2023-09-07 19:01:31 +08:00
if(self.cell != nil){
if(self.refreshComplete){
self.refreshComplete();
}
return;
}///
2023-07-14 18:50:55 +08:00
///退bug
@synchronized (self.presenter) {
2023-09-07 19:01:31 +08:00
if(self.isRequestData == YES){
if(self.refreshComplete){
self.refreshComplete();
}
return;
}
self.isRequestData = YES;
///
dispatch_group_t group =dispatch_group_create();
2023-07-14 18:50:55 +08:00
//
2023-09-07 19:01:31 +08:00
dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
2023-07-14 18:50:55 +08:00
2023-09-07 19:01:31 +08:00
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
[self.presenter getPlayGameWithTeam:1 withGroup:group];
});
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
[self.presenter getFriendListWithGroup:group];
});
2023-09-21 17:44:59 +08:00
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
[self.presenter getLittleGameListWithGroup:group];
});
2023-09-07 19:01:31 +08:00
dispatch_group_notify(group,dispatch_get_main_queue(), ^{
self.isRequestData = NO;
if(self.refreshComplete){
self.refreshComplete();
}
2023-10-07 09:57:48 +08:00
if(self.cell == nil){///
[self.tableView reloadData];
}
2023-09-07 19:01:31 +08:00
});
2023-07-14 18:50:55 +08:00
}
}
- (void)headerRefresh {
self.isRequestData = NO;
[self requestData];
}
2023-09-05 11:45:21 +08:00
2023-07-14 18:50:55 +08:00
#pragma mark - Private Method
- (void)initSubViews {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shieldingNotification) name:kShieldingNotification object:nil];
self.view.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
}
-(void)shieldingNotification{
[self requestData];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
2023-09-05 11:45:21 +08:00
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
2023-07-14 18:50:55 +08:00
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
2023-09-21 17:44:59 +08:00
if(section == 0) return 1;
2023-09-05 11:45:21 +08:00
return self.personalRoomList.count > 0 ? self.personalRoomList.count : 1;
2023-07-14 18:50:55 +08:00
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
2023-09-21 17:44:59 +08:00
return self.playTeamList.count > 0 ? kGetScaleWidth(102) : kGetScaleWidth(75);
2023-07-14 18:50:55 +08:00
}
2023-09-05 11:45:21 +08:00
return self.personalRoomList.count > 0 ? kGetScaleWidth(104) : 300;
2023-07-14 18:50:55 +08:00
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
2023-09-07 19:01:31 +08:00
if(indexPath.section == 0) {
2023-09-21 17:44:59 +08:00
if(self.playTeamList.count > 0){
XPNewHomePlayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
if (cell == nil) {
cell = [[XPNewHomePlayTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
}
cell.playRoomList = self.playTeamList;
cell.delegate = self;
return cell;
2023-09-07 19:01:31 +08:00
}
2023-09-05 11:45:21 +08:00
XPNewHomePlayEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
if (cell == nil) {
cell = [[XPNewHomePlayEmptyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
2023-07-14 18:50:55 +08:00
}
2023-09-05 11:45:21 +08:00
2023-09-21 17:44:59 +08:00
cell.isClan = YES;
cell.delegate = self;
2023-09-05 11:45:21 +08:00
return cell;
2023-09-21 17:44:59 +08:00
2023-09-05 11:45:21 +08:00
}
2023-09-07 19:01:31 +08:00
2023-09-21 17:44:59 +08:00
2023-09-07 19:01:31 +08:00
XPNewHomePartyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePartyTableViewCell class])];
if (cell == nil) {
cell = [[XPNewHomePartyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePartyTableViewCell class])];
}
cell.roomInfo = [self.personalRoomList safeObjectAtIndex1:indexPath.row];
cell.delegate = self;
return cell;
2023-09-05 11:45:21 +08:00
2023-07-14 18:50:55 +08:00
}
2023-09-05 11:45:21 +08:00
2023-09-07 19:01:31 +08:00
2023-07-14 18:50:55 +08:00
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
2023-09-07 19:01:31 +08:00
2023-07-14 18:50:55 +08:00
return 0.01;
2023-09-07 19:01:31 +08:00
}
2023-07-14 18:50:55 +08:00
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.01;
}
2023-09-07 19:01:31 +08:00
2023-09-05 11:45:21 +08:00
2023-07-14 18:50:55 +08:00
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if(indexPath.section == 3) {
if (self.personalRoomList.count > 0) {
HomePlayRoomModel * roomInfo1 = [self.personalRoomList safeObjectAtIndex1:indexPath.row];
if (roomInfo1.uid.length > 0) {
[XPRoomViewController openRoom:roomInfo1.uid viewController:self];
}
}
}
}
2023-09-07 19:01:31 +08:00
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
if(self.cell != nil){
if(scrollView.contentOffset.y > self.cellY){
[self.countDownHelper stopCountDown];
self.countDownHelper .delegate = nil;
[[XPSkillCardPlayerManager shareInstance] stopMusic];
[self.cell setPlaySoundStatus:NO];
self.cell = nil;
}
}
if(self.scrollCallback){
self.scrollCallback(scrollView);
}
}
2023-07-14 18:50:55 +08:00
#pragma mark - XPNewHomeRecommendTableViewCellDelegate
- (void)xPNewHomeRecommendTableViewCell:(XPNewHomeRecommendTableViewCell *)view didSelectItem:(HomeRecommendRoomModel *)info {
if (info.roomUid.length > 0) {
[XPRoomViewController openRoom:info.roomUid viewController:self];
}
}
#pragma mark - XPNewHomePlayTableViewCellDelegate
- (void)xPNewHomePlayTableViewCell:(XPNewHomePlayTableViewCell *)cell didSelectItem:(HomePlayRoomModel *)info {
if (info.uid.length > 0) {
[XPRoomViewController openRoom:info.uid viewController:self];
}
}
- (void)chooseGameAction{
2023-09-21 17:44:59 +08:00
// XPHomeGameView *gameView = [XPHomeGameView new];
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
// gameView.playGameList = self.littleGameArray;
// gameView.delegate = self;
// [kWindow addSubview:gameView];
2023-07-14 18:50:55 +08:00
}
#pragma mark - XPNewHomePlayEmptyTableViewCellDelegate
- (void)emptyCellChooseGameAction{
2023-09-21 17:44:59 +08:00
// XPHomeGameView *gameView = [XPHomeGameView new];
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
// gameView.playGameList = self.littleGameArray;
// gameView.delegate = self;
// [kWindow addSubview:gameView];
2023-09-25 16:02:57 +08:00
if(self.delegate && [self.delegate respondsToSelector:@selector(openRoom)]){
[self.delegate openRoom];
}
2023-09-21 17:44:59 +08:00
}
#pragma mark - XPHomeGameViewDelegate
- (void)xpHomeGameViewChooseGameWithGameModel:(LittleGameInfoModel *)gameModel{
NSString * uid = [AccountInfoStorage instance].getUid;
[self showLoading];
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data];
if(roomInfo.isReselect){
[XPRoomViewController openRoom:[AccountInfoStorage instance].getUid mgId:gameModel.mgId viewController:self];
}else{
[self updateRoomInformation:gameModel roomInfo:roomInfo];
}
} else {
[self hideHUD];
[self showErrorToast:msg];
}
} uid:uid intoUid:uid];
}
///
-(void)updateRoomInformation:(LittleGameInfoModel *)gameModel roomInfo:(RoomInfoModel *)roomInfo{
NSString * uid = [AccountInfoStorage instance].getUid;
NSMutableDictionary * params = [NSMutableDictionary dictionary];
NSString * ticket = [AccountInfoStorage instance].getTicket;
[params setObject:ticket forKey:@"ticket"];
[params setObject:uid forKey:@"uid"];
[params setObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"];
if (roomInfo.title.length > 0) {
[params setObject:roomInfo.title forKey:@"title"];
}
if (roomInfo.roomPwd.length > 0) {
[params setObject:roomInfo.roomPwd forKey:@"roomPwd"];
} else{
[params setObject:@"" forKey:@"roomPwd"];
}
if (roomInfo.tagId > 0) {
[params setObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"];
}
[params setObject:@(RoomType_MiniGame) forKey:@"type"];
[params setObject:gameModel.mgId forKey:@"mgId"];
[params setObject:@(roomInfo.hasAnimationEffect) forKey:@"hasAnimationEffect"];
@weakify(self)
[Api ownerUpdateRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@strongify(self);
[self hideHUD];
if (code == 200) {
[XPRoomViewController openRoom:[AccountInfoStorage instance].getUid mgId:gameModel.mgId viewController:self];
} else {
[self showErrorToast:msg];
}
} params:params];
2023-07-14 18:50:55 +08:00
}
#pragma mark - XPHomeBannerTableViewCell
- (void)xPHomeBannerTableViewCell:(XPHomeBannerTableViewCell *)view didClickBanner:(HomeBannerInfoModel *)info {
switch (info.skipType) {
case HomeBannerInfoSkipType_Room:
{
if (info.skipUri.length > 0) {
[XPRoomViewController openRoom:info.skipUri viewController:self];
}
}
break;
case HomeBannerInfoSkipType_Web:
{
XPWebViewController *vc = [[XPWebViewController alloc]init];
vc.url = info.skipUri;
[self.navigationController pushViewController:vc animated:YES];
}
break;
default:
break;
}
}
#pragma mark - XPHomeRecommendProtocol
2023-09-05 11:45:21 +08:00
2023-07-14 18:50:55 +08:00
2023-09-05 15:37:02 +08:00
///
- (void)getPlayGameWithTeamSuccess:(NSArray *)list withGroup:(nonnull dispatch_group_t)group{
self.playTeamList = [NSMutableArray arrayWithArray:list];
dispatch_group_leave(group);
2023-07-14 18:50:55 +08:00
}
2023-09-05 15:37:02 +08:00
- (void)getHomeRecommendDataFailWithGroup:(dispatch_group_t)group{
2023-07-14 18:50:55 +08:00
dispatch_group_leave(group);
}
2023-09-05 15:37:02 +08:00
- (void)getFriendListSuccess:(NSArray *)list withGroup:(dispatch_group_t)group{
2023-09-07 19:01:31 +08:00
for (int i = 0;i < list.count;i++) {
HomePlayRoomModel *model = list[i];
NSMutableArray *labels = [NSMutableArray array];
[labels addObject:[NSString calculateConstellationWithMonth:model.birth] ?: @""];
[labels addObjectsFromArray:model.labels];
model.labels = labels;
NSMutableArray *widthList = [NSMutableArray array];
for (NSString *text in model.labels) {
CGFloat width = [UILabel getWidthWithText:text height:kGetScaleWidth(18) font:kFontRegular(10)] + kGetScaleWidth(16) + 1;
[widthList addObject:@(width)];
}
model.labelsWidthList = widthList;
}
2023-09-05 15:37:02 +08:00
self.personalRoomList = [NSMutableArray arrayWithArray:list];
2023-07-14 18:50:55 +08:00
dispatch_group_leave(group);
}
2023-09-21 17:44:59 +08:00
- (void)onGetLittleGameListSuccess:(NSArray<LittleGameInfoModel *> *)items withGroup:(nonnull dispatch_group_t)group{
self.littleGameArray = [[NSMutableArray alloc]initWithArray:items];
dispatch_group_leave(group);
}
2023-09-05 15:37:02 +08:00
- (void)getFriendListFailWithGroup:(dispatch_group_t)group{
2023-07-14 18:50:55 +08:00
dispatch_group_leave(group);
}
2023-09-01 18:58:41 +08:00
#pragma mark - JXPagingViewListViewDelegate
- (UIScrollView *)listScrollView {
return self.tableView;
}
- (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
self.scrollCallback = callback;
}
2023-07-14 18:50:55 +08:00
- (UIView *)listView {
return self.view;
}
2023-09-07 19:01:31 +08:00
#pragma mark- XPNewHomePartyTableViewCellDelegate
///
-(void)xPNewHomePartyTableViewCell:(XPNewHomePartyTableViewCell *_Nullable)cell didSelectItem:(HomePlayRoomModel *_Nullable)roomModel{
XPMineUserInfoViewController *infoVC = [[XPMineUserInfoViewController alloc]init];
infoVC.uid = [roomModel.uid integerValue];
[self.navigationController pushViewController:infoVC animated:YES];
}
///
-(void)xPNewHomePartyTableViewCell:(XPNewHomePartyTableViewCell *_Nullable)cell didSelectChat:(HomePlayRoomModel *_Nonnull)roomModel{
if(roomModel.inMic == YES){
2023-09-27 23:56:16 +08:00
[XPRoomViewController openRoom:roomModel.inRoomUid fromNick:roomModel.nick fromType:UserEnterRoomFromType_Follow_User fromUid:roomModel.uid viewController:self];
2023-09-07 19:01:31 +08:00
return;
2023-09-01 18:58:41 +08:00
}
2023-09-07 19:01:31 +08:00
NIMSession * session = [NIMSession session:roomModel.uid type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
[self.navigationController pushViewController:sessionVC animated:YES];
2023-09-01 18:58:41 +08:00
}
2023-09-07 19:01:31 +08:00
///
-(void)xPNewHomePartyTableViewCell:(XPNewHomePartyTableViewCell *_Nullable)cell didPlayVoice:(HomePlayRoomModel *_Nonnull)roomModel didClickPlaySound:(BOOL)isPlay{
if(isPlay == YES){
2023-09-08 18:05:46 +08:00
if(self.cell != nil){
[self.countDownHelper stopCountDown];
[self.cell setPlaySoundStatus:NO];
[[XPSkillCardPlayerManager shareInstance] stopMusic];
self.cell = nil;
}
2023-09-07 19:01:31 +08:00
self.cell = cell;
CGRect cellRect = [self.tableView rectForRowAtIndexPath:[self.tableView indexPathForCell:self.cell]];
2023-09-08 18:05:46 +08:00
self.cellY = cellRect.origin.y + cellRect.size.height;
2023-09-07 19:01:31 +08:00
NSString *fileName = [[roomModel.userVoice componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"kMineSoundCard"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
[self playAudioWithUrl:fullPath isDelay:[XPSkillCardPlayerManager shareInstance].isMineInMic];
}else{
if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
NSFileManager *fileMgr = [[NSFileManager alloc] init];
[fileMgr createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
}
[UploadFile downloadAudioWithFileName:fileName musicUrl:roomModel.userVoice mainFileName:@"kMineSoundCard" completion:^(BOOL isSuccess, NSString *editAudioPath) {
if(isSuccess){
[self playAudioWithUrl:editAudioPath isDelay:[XPSkillCardPlayerManager shareInstance].isMineInMic];
}else{
[self.cell setPlaySoundStatus:NO];
[[XPSkillCardPlayerManager shareInstance] stopMusic];
self.cell = nil;
}
}];
}
}else{
[self.countDownHelper stopCountDown];
[self.cell setPlaySoundStatus:NO];
[[XPSkillCardPlayerManager shareInstance] stopMusic];
self.cell = nil;
}
}
///
/// - Parameters:
/// - url:
/// - isDelay: 0.50.5
-(void)playAudioWithUrl:(NSString*)url isDelay:(BOOL)isDelay{
if(isDelay == YES){
[[XPSkillCardPlayerManager shareInstance] playerNewVoiceWithPath:url completionBlock:^{
[[XPSkillCardPlayerManager shareInstance] stopMusic];
}];
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
NSInteger getCurrentTime = ceil([self.cell.roomInfo.voiceDura integerValue]);
[self.countDownHelper openCountdownWithTime:(int)getCurrentTime];
});
return;
}
NSInteger getCurrentTime = ceil([self.cell.roomInfo.voiceDura integerValue]);
[self.countDownHelper openCountdownWithTime:(int)getCurrentTime];
[[XPSkillCardPlayerManager shareInstance] playerVoiceWithPath:url completionBlock:^{
[[XPSkillCardPlayerManager shareInstance] stopMusic];
}];
}
///
- (void)onCountdownFinish{
if(self.cell != nil){
[self.cell setPlaySoundTime:0];
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.cell setPlaySoundStatus:NO];
self.cell = nil;
});
}
}
///
- (void)onCountdownOpen:(int)time{
if(self.cell != nil){
[self.cell setPlaySoundTime:(int)time + 1];
}
}
2023-07-14 18:50:55 +08:00
- (UITableView *)tableView {
if (!_tableView) {
2023-09-05 11:45:21 +08:00
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
2023-07-14 18:50:55 +08:00
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[_tableView registerClass:[XPNewHomePlayTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
[_tableView registerClass:[XPNewHomePlayEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
[_tableView registerClass:[XPNewHomePartyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPNewHomePartyTableViewCell class])];
}
return _tableView;
}
2023-09-07 19:01:31 +08:00
- (CountDownHelper *)countDownHelper{
if (!_countDownHelper){
_countDownHelper = [[CountDownHelper alloc]init];
}
return _countDownHelper;
}
2023-07-14 18:50:55 +08:00
@end