修复bug

This commit is contained in:
liyuhua
2023-10-18 15:11:56 +08:00
parent 63492e37cf
commit 83c26770a4
13 changed files with 128 additions and 63 deletions

View File

@@ -61,11 +61,9 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
///
@property (nonatomic,strong) CountDownHelper *countDownHelper;
///cell
@property(nonatomic,strong)XPNewHomePartyTableViewCell *cell;
///cellUITableViewY
@property(nonatomic,assign) CGFloat cellY;
///cellUITableViewY
@property(nonatomic,assign) CGFloat cellMinY;
@property(nonatomic,strong)XPNewHomePartyTableViewCell *pi_playAudioCell;
///
@property (nonatomic, strong) NSMutableArray<LittleGameInfoModel *> *littleGameArray;
@end
@@ -87,7 +85,7 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
}
@@ -96,9 +94,9 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
[super viewDidAppear:animated];
[self.countDownHelper stopCountDown];
[[XPSkillCardPlayerManager shareInstance] stopMusic];
if(self.cell != nil){
[self.cell setPlaySoundStatus:NO];
self.cell = nil;
if(self.pi_playAudioCell != nil){
[self.pi_playAudioCell setPlaySoundStatus:NO];
self.pi_playAudioCell = nil;
}
@@ -109,7 +107,7 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
#pragma mark - InitHttp
-(void)requestData{
if(self.cell != nil){
if(self.pi_playAudioCell != nil){
if(self.refreshComplete){
self.refreshComplete();
}
@@ -144,7 +142,7 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
});
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
[self.presenter getLittleGameListWithGroup:group];
});
@@ -154,10 +152,10 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
if(self.refreshComplete){
self.refreshComplete();
}
if(self.cell == nil){///
if(self.pi_playAudioCell == nil){///
[self.tableView reloadData];
}
});
@@ -220,14 +218,14 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
cell = [[XPNewHomePlayEmptyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
}
cell.isClan = YES;
cell.delegate = self;
return cell;
}
XPNewHomePartyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePartyTableViewCell class])];
if (cell == nil) {
@@ -269,14 +267,21 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
if(self.cell != nil){
if(scrollView.contentOffset.y > self.cellY){
if(self.pi_playAudioCell != nil){
BOOL isVisible = YES;
CGRect cellR = [self.tableView rectForRowAtIndexPath:[self.tableView indexPathForCell:self.pi_playAudioCell]];
if((self.tableView.contentOffset.y - (cellR.origin.y)) > cellR.size.height){
isVisible = NO;
}
if (cellR.origin.y - self.tableView.contentOffset.y > self.tableView.frame.size.height) {//
isVisible = NO;
}
if(!isVisible && [self.pi_playAudioCell isKindOfClass:[XPNewHomePartyTableViewCell class]]) {
[self.countDownHelper stopCountDown];
[[XPSkillCardPlayerManager shareInstance] stopMusic];
[self.cell setPlaySoundStatus:NO];
self.cell = nil;
[self.pi_playAudioCell setPlaySoundStatus:NO];
self.pi_playAudioCell = nil;
}
}
if(self.scrollCallback){
self.scrollCallback(scrollView);
@@ -297,26 +302,26 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
}
}
- (void)chooseGameAction{
// XPHomeGameView *gameView = [XPHomeGameView new];
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
// gameView.playGameList = self.littleGameArray;
// gameView.delegate = self;
// [kWindow addSubview:gameView];
// XPHomeGameView *gameView = [XPHomeGameView new];
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
// gameView.playGameList = self.littleGameArray;
// gameView.delegate = self;
// [kWindow addSubview:gameView];
}
#pragma mark - XPNewHomePlayEmptyTableViewCellDelegate
- (void)emptyCellChooseGameAction{
// XPHomeGameView *gameView = [XPHomeGameView new];
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
// gameView.playGameList = self.littleGameArray;
// gameView.delegate = self;
// [kWindow addSubview:gameView];
// XPHomeGameView *gameView = [XPHomeGameView new];
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
// gameView.playGameList = self.littleGameArray;
// gameView.delegate = self;
// [kWindow addSubview:gameView];
if(self.delegate && [self.delegate respondsToSelector:@selector(openRoom)]){
[self.delegate openRoom];
}
}
#pragma mark - XPHomeGameViewDelegate
- (void)xpHomeGameViewChooseGameWithGameModel:(LittleGameInfoModel *)gameModel{
NSString * uid = [AccountInfoStorage instance].getUid;
[self showLoading];
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@@ -429,7 +434,7 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
dispatch_group_leave(group);
}
- (void)onGetLittleGameListSuccess:(NSArray<LittleGameInfoModel *> *)items withGroup:(nonnull dispatch_group_t)group{
self.littleGameArray = [[NSMutableArray alloc]initWithArray:items];
dispatch_group_leave(group);
}
@@ -474,16 +479,15 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
///
-(void)xPNewHomePartyTableViewCell:(XPNewHomePartyTableViewCell *_Nullable)cell didPlayVoice:(HomePlayRoomModel *_Nonnull)roomModel didClickPlaySound:(BOOL)isPlay{
if(isPlay == YES){
if(self.cell != nil){
if(self.pi_playAudioCell != nil){
[self.countDownHelper stopCountDown];
[self.cell setPlaySoundStatus:NO];
[self.pi_playAudioCell setPlaySoundStatus:NO];
[[XPSkillCardPlayerManager shareInstance] stopMusic];
self.cell = nil;
self.pi_playAudioCell = nil;
}
self.cell = cell;
CGRect cellRect = [self.tableView rectForRowAtIndexPath:[self.tableView indexPathForCell:self.cell]];
self.cellY = cellRect.origin.y + cellRect.size.height;
self.cellMinY = (cellRect.size.height + self.tableView.frame.size.height);
self.pi_playAudioCell = cell;
NSString *fileName = [[roomModel.userVoice componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"kMineSoundCard"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
@@ -499,17 +503,17 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
[self playAudioWithUrl:editAudioPath isDelay:[XPSkillCardPlayerManager shareInstance].isMineInMic];
}else{
[self.cell setPlaySoundStatus:NO];
[self.pi_playAudioCell setPlaySoundStatus:NO];
[[XPSkillCardPlayerManager shareInstance] stopMusic];
self.cell = nil;
self.pi_playAudioCell = nil;
}
}];
}
}else{
[self.countDownHelper stopCountDown];
[self.cell setPlaySoundStatus:NO];
[self.pi_playAudioCell setPlaySoundStatus:NO];
[[XPSkillCardPlayerManager shareInstance] stopMusic];
self.cell = nil;
self.pi_playAudioCell = nil;
}
}
@@ -526,12 +530,12 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
}];
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]);
NSInteger getCurrentTime = ceil([self.pi_playAudioCell.roomInfo.voiceDura integerValue]);
[self.countDownHelper openCountdownWithTime:(int)getCurrentTime];
});
return;
}
NSInteger getCurrentTime = ceil([self.cell.roomInfo.voiceDura integerValue]);
NSInteger getCurrentTime = ceil([self.pi_playAudioCell.roomInfo.voiceDura integerValue]);
[self.countDownHelper openCountdownWithTime:(int)getCurrentTime];
[[XPSkillCardPlayerManager shareInstance] playerVoiceWithPath:url completionBlock:^{
@@ -540,19 +544,19 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
}
///
- (void)onCountdownFinish{
if(self.cell != nil){
[self.cell setPlaySoundTime:0];
if(self.pi_playAudioCell != nil){
[self.pi_playAudioCell 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;
[self.pi_playAudioCell setPlaySoundStatus:NO];
self.pi_playAudioCell = nil;
});
}
}
///
- (void)onCountdownOpen:(int)time{
if(self.cell != nil){
[self.cell setPlaySoundTime:(int)time + 1];
if(self.pi_playAudioCell != nil){
[self.pi_playAudioCell setPlaySoundTime:(int)time + 1];
}
}