From 1723782767909e3c78c9def40b465dd3e1ae05be Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Wed, 15 May 2024 17:35:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BC=E7=89=A9=E5=8A=A8=E6=95=88=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/Session/MSSessionPublicChatHallVC.m | 7 + .../View/AnimationView/XPRoomAnimationView.m | 40 +- .../YMRoom/View/SendGiftView/Api/Api+Gift.h | 4 +- .../YMRoom/View/SendGiftView/Api/Api+Gift.m | 6 + .../Modules/YMRoom/View/StageView/StageView.m | 5 +- .../View/View/XPTreasureFairyStoreView.m | 10 +- .../View/XPTreasureFairyTrialsContentView.m | 10 +- .../YMTabbar/View/TabbarViewController.m | 613 +++++++++--------- YuMi/Tools/File/UploadFile.m | 3 +- YuMi/en.lproj/Localizable.strings | 4 +- YuMi/zh-Hans.lproj/Localizable.strings | 4 +- YuMi/zh-Hant.lproj/Localizable.strings | 4 +- 12 files changed, 379 insertions(+), 331 deletions(-) diff --git a/YuMi/Modules/YMMessage/View/Session/MSSessionPublicChatHallVC.m b/YuMi/Modules/YMMessage/View/Session/MSSessionPublicChatHallVC.m index 14bf4ae6..58df0b0e 100644 --- a/YuMi/Modules/YMMessage/View/Session/MSSessionPublicChatHallVC.m +++ b/YuMi/Modules/YMMessage/View/Session/MSSessionPublicChatHallVC.m @@ -575,6 +575,9 @@ [self.messages removeObjectsInArray:needRemoveMsgArray]; } for (NIMMessage *message in messages) { + if (![self isCanAddMsg:message]){ + return; + } [self addTimeMessage:message]; if (message.isDeleted) { continue; @@ -599,7 +602,11 @@ if (message.session.sessionType != NIMSessionTypeChatroom) { return; } + if (![self isCanAddMsg:message]){ + return; + } [self addTimeMessage:message]; + if (![self isExistMessages:message]) { if ([self isCanAddMsg:message]){ [self addTimeMessage:message]; diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m index 011737bb..2f49981a 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m @@ -2053,11 +2053,11 @@ ///播放礼物特效 SVGA的 - (void)playGiftEffect:(NSString *)vggUrl { if ([self isInSudGame]) {return;} - NSString *baseFileName = @"/GiftSvga"; - NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vggUrl]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - if ([fileManager fileExistsAtPath:filePath]){ - NSData *data=[NSData dataWithContentsOfFile:filePath options:0 error:NULL]; + NSString *fileName = [[vggUrl componentsSeparatedByString:@"/"] lastObject]; + NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"]; + NSString *fullPath = [filePath stringByAppendingPathComponent:fileName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){ + NSData *data=[NSData dataWithContentsOfFile:fullPath options:0 error:NULL]; [self.parser parseWithData:data cacheKey:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { if (videoItem != nil) { @@ -2161,11 +2161,11 @@ ///播放礼物特效 vap的 - (void)playGiftEffectWithVapUrl:(NSString *)vapUrl { - NSString *baseFileName = @"/GiftMp4"; - NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vapUrl]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - if ([fileManager fileExistsAtPath:filePath]){ - vapUrl = filePath; + NSString *fileName = [[vapUrl componentsSeparatedByString:@"/"] lastObject]; + NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"]; + NSString *fullPath = [filePath stringByAppendingPathComponent:fileName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){ + vapUrl = fullPath; self.vapGiftEffectView.hidden = NO; if (self.vapGiftEffectView.superview == nil) { @@ -2205,11 +2205,11 @@ if ([self isInSudGame]) {return;} - NSString *baseFileName = @"/GiftSvga"; - NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vggUrl.absoluteString]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - if ([fileManager fileExistsAtPath:filePath]){ - NSData *data=[NSData dataWithContentsOfFile:filePath options:0 error:NULL]; + NSString *fileName = [[vggUrl.absoluteString componentsSeparatedByString:@"/"] lastObject]; + NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"]; + NSString *fullPath = [filePath stringByAppendingPathComponent:fileName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){ + NSData *data=[NSData dataWithContentsOfFile:fullPath options:0 error:NULL]; [self.parser parseWithData:data cacheKey:@"" completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { if (videoItem != nil) { self.luckyGiftEffectView.hidden = NO; @@ -2284,11 +2284,11 @@ ///播放礼物特效 vap的 - (void)playLuckyGiftEffectWithVapUrl:(NSString *)vapUrl { - NSString *baseFileName = @"/GiftMp4"; - NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vapUrl]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - if ([fileManager fileExistsAtPath:filePath]){ - vapUrl = filePath; + NSString *fileName = [[vapUrl componentsSeparatedByString:@"/"] lastObject]; + NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"]; + NSString *fullPath = [filePath stringByAppendingPathComponent:fileName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){ + vapUrl = fullPath; self.luckyVapGiftEffectView.hidden = NO; if (self.luckyVapGiftEffectView.superview == nil) { [self.middleLevelView addSubview:self.luckyVapGiftEffectView]; diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.h b/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.h index a4338474..99248039 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.h +++ b/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.h @@ -77,8 +77,10 @@ NS_ASSUME_NONNULL_BEGIN + (void)requestTwelveStarFirst:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid; /// 请求缓存列表 /// @param complection 完成 -/// @param roomUid 房间的roomuid + (void)requestCacheGiftList:(HttpRequestHelperCompletion)complection; +/// 请求新礼物动效缓存列表 +/// @param complection 完成 ++(void)requestCacheGiftDynamicEffectList:(HttpRequestHelperCompletion)complection; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.m b/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.m index eb33d5dd..7a27dd1b 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.m @@ -32,6 +32,12 @@ NSString * fang = @"gift/vgg"; [self makeRequest:fang method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, nil]; } +/// 请求新礼物动效缓存列表 +/// @param complection 完成 ++(void)requestCacheGiftDynamicEffectList:(HttpRequestHelperCompletion)complection{ + NSString * fang = @"resource/effect"; + [self makeRequest:fang method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, nil]; +} /// 请求福袋全服礼物全服记录 /// @param complection 完成 + (void)requestLuckGiftServerBagRecord:(HttpRequestHelperCompletion)complection { diff --git a/YuMi/Modules/YMRoom/View/StageView/StageView.m b/YuMi/Modules/YMRoom/View/StageView/StageView.m index 429c4c34..77d7b839 100644 --- a/YuMi/Modules/YMRoom/View/StageView/StageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/StageView.m @@ -190,10 +190,11 @@ if(meQuence != nil){ [self enterRoomUpMicWith:meQuence]; } + // 拿到麦序后初始化礼物值 + [self initGiftValue]; }]; - // 拿到麦序后初始化礼物值 - [self initGiftValue]; + } ///进入房间,如果自己在麦上,需要调下上麦,不然,网络不好,会导致人不在麦上,但有声音 -(void)enterRoomUpMicWith:(MicroQueueModel *)sequence{ diff --git a/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyStoreView.m b/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyStoreView.m index fdbd48ad..2b73b2d5 100644 --- a/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyStoreView.m +++ b/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyStoreView.m @@ -480,12 +480,12 @@ make.edges.mas_equalTo(self.forestImageView); }]; - NSString *baseFileName = @"/GiftMp4"; - NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:animtionName]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - if ([fileManager fileExistsAtPath:filePath]){ + NSString *fileName = [[animtionName componentsSeparatedByString:@"/"] lastObject]; + NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"]; + NSString *fullPath = [filePath stringByAppendingPathComponent:fileName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){ [view setMute:YES]; - [view playHWDMP4:filePath repeatCount:1 delegate:self]; + [view playHWDMP4:fullPath repeatCount:1 delegate:self]; }else{ [self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) { diff --git a/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyTrialsContentView.m b/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyTrialsContentView.m index 22d61678..40371b88 100644 --- a/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyTrialsContentView.m +++ b/YuMi/Modules/YMRoom/View/TreasureFairy/View/View/XPTreasureFairyTrialsContentView.m @@ -284,12 +284,12 @@ make.edges.equalTo(self.trialsBgImageView); }]; } - NSString *baseFileName = @"/GiftMp4"; - NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:animtionName]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - if ([fileManager fileExistsAtPath:filePath]){ + NSString *fileName = [[animtionName componentsSeparatedByString:@"/"] lastObject]; + NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"]; + NSString *fullPath = [filePath stringByAppendingPathComponent:fileName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){ [self.trialsView setMute:YES]; - [self.trialsView playHWDMP4:filePath repeatCount:1 delegate:self]; + [self.trialsView playHWDMP4:fullPath repeatCount:1 delegate:self]; }else{ [self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) { diff --git a/YuMi/Modules/YMTabbar/View/TabbarViewController.m b/YuMi/Modules/YMTabbar/View/TabbarViewController.m index 2b963cdf..a822c297 100644 --- a/YuMi/Modules/YMTabbar/View/TabbarViewController.m +++ b/YuMi/Modules/YMTabbar/View/TabbarViewController.m @@ -96,7 +96,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; @interface TabbarViewController () { - NSTimer * timer; + NSTimer * timer; } ///用户信息 @property (nonatomic,strong) UserInfoModel *userInfo; @@ -138,7 +138,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } - (void)viewDidLoad { [super viewDidLoad]; - + [self.presenter autoLogin]; [self configTheme]; @@ -151,7 +151,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; [[NIMSDK sharedSDK].chatManager addDelegate:self]; [[NIMSDK sharedSDK].systemNotificationManager addDelegate:self]; [[NIMSDK sharedSDK].broadcastManager addDelegate:self]; - + [self networkReachability]; [self.view addSubview:self.roomMineView]; @kWeakify(self); @@ -159,8 +159,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; @kStrongify(self); [self configRoomMiniNView:note.userInfo]; }]; - - + + [[NSNotificationCenter defaultCenter] addObserverForName:@"reloadnewtab" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { @kStrongify(self); if (self.isInitReload == NO) { @@ -171,12 +171,12 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNewUserRecharge) name:kNewUserRechargeKey object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil]; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage:) name:@"kSwitchLanguage" object:nil]; - - - + + + } -(void)switchLanguage:(NSNotification *)not{ [self initTabs:YES]; @@ -288,10 +288,10 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; self.inviteCode = nil; } [self monentsUnReadCount]; - + } - - + + } -(void)loginIng{ if ((self.userInfo.nick == nil || self.userInfo.avatar == nil) && self.isFormLogin == NO) { @@ -310,7 +310,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; self.inviteCode = nil; } [self monentsUnReadCount]; - + } } - (void)getAuthorizationCodeInfoWithPhonefail{ @@ -336,39 +336,50 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; /// -(void)requestGiftList{ [self dealWithDefaultSvga]; -///所有礼物接口,缓存礼物,保存时间,一天只请求一次 - NSString *time = [NSDate getNowTimeTimestamp]; - NSString *curTime = [NSDate timestampSwitchTime:[time integerValue] andFormatter:@"yyyy-MM-dd"]; - NSDictionary *timeDic = [[NSUserDefaults standardUserDefaults]valueForKey:@"kRequestGiftList"]; - if(timeDic == nil){ - NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic]; - [curDic setValue:@(YES) forKey:curTime]; - [[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"]; - [[NSUserDefaults standardUserDefaults]synchronize]; - }else{ - if(timeDic[curTime]!= nil)return; - NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic]; - [curDic removeAllObjects]; - [curDic setValue:@(YES) forKey:curTime]; - [[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"]; - [[NSUserDefaults standardUserDefaults]synchronize]; - } + ///所有礼物接口,缓存礼物,保存时间,一天只请求一次 + // NSString *time = [NSDate getNowTimeTimestamp]; + // NSString *curTime = [NSDate timestampSwitchTime:[time integerValue] andFormatter:@"yyyy-MM-dd"]; + // NSDictionary *timeDic = [[NSUserDefaults standardUserDefaults]valueForKey:@"kRequestGiftList"]; + // if(timeDic == nil){ + // NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic]; + // [curDic setValue:@(YES) forKey:curTime]; + // [[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"]; + // [[NSUserDefaults standardUserDefaults]synchronize]; + // }else{ + // if(timeDic[curTime]!= nil)return; + // NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic]; + // [curDic removeAllObjects]; + // [curDic setValue:@(YES) forKey:curTime]; + // [[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"]; + // [[NSUserDefaults standardUserDefaults]synchronize]; + // } [Api requestCacheGiftList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if(code == 200){ NSArray *giftList = [GiftInfoModel modelsWithArray:data.data]; for (GiftInfoModel *giftModel in giftList) { if(giftModel.vggUrl.length > 0){ - [self dealWithGiftListWithUrl:giftModel.vggUrl fileName:giftModel.vggUrl isSvga:YES]; + NSString *url = [giftModel.vggUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet]; + [self dealWithGiftListWithUrl:url isSvga:YES]; }else if(giftModel.viewUrl.length > 0){ - [self dealWithGiftListWithUrl:giftModel.viewUrl fileName:giftModel.viewUrl isSvga:NO]; + NSString *url = [giftModel.viewUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet]; + [self dealWithGiftListWithUrl:url isSvga:NO]; } - + + } + } + }]; + + [Api requestCacheGiftDynamicEffectList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if(code == 200){ + NSArray *list = data.data; + NSSet *setList = [[NSSet alloc]initWithArray:list]; + for (NSString *url in setList) { + NSString *encodingUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet]; + [self cacheGiftDynamicEffectList:encodingUrl]; } } }]; - - } -(void)dealWithDefaultSvga{ @@ -376,70 +387,90 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; ///夺宝精灵动效 NSArray *elfList = @[@"https://image.hfighting.com/fenjie2.mp4",@"https://image.hfighting.com/treasure_fairy_ten.mp4",@"https://image.hfighting.com/hecheng3.mp4",@"https://image.hfighting.com/treasure_fairy_one.mp4"]; for (NSString *url in elfList) { - [self dealWithGiftListWithUrl:url fileName:url isSvga:NO]; + NSString *encodingUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet]; + [self cacheGiftDynamicEffectList:encodingUrl]; + [self dealWithGiftListWithUrl:encodingUrl isSvga:NO]; } } --(void)dealWithGiftListWithUrl:(NSString *)url fileName:(NSString *)fileName isSvga:(BOOL)isSvga { - NSString *baseFileName = isSvga ? @"/GiftSvga":@"/GiftMp4"; - NSString *filePaths = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:fileName]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - if ([[NSFileManager defaultManager] fileExistsAtPath:filePaths])return; - [[[NSURLSession sharedSession] downloadTaskWithURL:[NSURL URLWithString:url] completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) { - if(!error){ - [fileManager createDirectoryAtPath:[filePaths stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:nil]; - NSData *data = [NSData dataWithContentsOfURL:location]; - [data writeToFile:filePaths atomically:YES]; +///缓存新的礼物动效数据 +-(void)cacheGiftDynamicEffectList:(NSString *)url{ + + NSString *fileName = [[url componentsSeparatedByString:@"/"] lastObject]; + NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"]; + NSString *fullPath = [filePath stringByAppendingPathComponent:fileName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) { + return; + } + NSFileManager *fileMgr = [[NSFileManager alloc] init]; + [fileMgr createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil]; + [UploadFile downloadAudioWithFileName:fileName musicUrl:url mainFileName:@"GiftDynamicEffectList" completion:^(BOOL isSuccess, NSString *editAudioPath) { + if(isSuccess){ + + + }else{ + } - }] resume]; - + }]; +} +-(void)dealWithGiftListWithUrl:(NSString *)url isSvga:(BOOL)isSvga { + ///删除旧数据缓存, + NSString *baseFileName = isSvga ? @"/GiftSvga":@"/GiftMp4"; + NSString *oldFilePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:oldFilePath]) { + BOOL isSuccess = [[NSFileManager defaultManager]removeItemAtPath:oldFilePath error:nil]; + if(isSuccess == YES){ + NSLog(@"删除成功"); + } + + } } - (void)checkInviteUserInfoSuccess:(InviteUserInfoModel *)inviteInfo { - if (inviteInfo && inviteInfo.isInRoom) { - [XPRoomViewController openRoom:inviteInfo.roomUid fromNick:inviteInfo.inviteNick fromType:inviteInfo.fromType fromUid:inviteInfo.inviteUid viewController:self]; - } else { //不在房间 - [self.presenter getShortCutRecommendRoom]; - } + if (inviteInfo && inviteInfo.isInRoom) { + [XPRoomViewController openRoom:inviteInfo.roomUid fromNick:inviteInfo.inviteNick fromType:inviteInfo.fromType fromUid:inviteInfo.inviteUid viewController:self]; + } else { //不在房间 + [self.presenter getShortCutRecommendRoom]; + } } - (void)getShortCutRecommendRoomSuccces:(NSString *)roomUid { - if (roomUid.length > 0) { - [XPRoomViewController openRoom:roomUid viewController:self]; - } + if (roomUid.length > 0) { + [XPRoomViewController openRoom:roomUid viewController:self]; + } } #pragma mark - app 启动调用此接口 主要功能: 给主播分流 - (void)clientStartApp { -// [self.presenter clientStartApp]; + // [self.presenter clientStartApp]; } #pragma mark - 网络状态监听 - (void)networkReachability{ -// @kWeakify(self); -// [[AFNetworkReachabilityManager sharedManager] startMonitoring]; -// [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { -// @kStrongify(self); -// switch (status) { -// case AFNetworkReachabilityStatusUnknown: -// self.isFirstReachability = YES; -// break; -// case AFNetworkReachabilityStatusNotReachable: -// self.isFirstReachability = YES; -// break; -// case AFNetworkReachabilityStatusReachableViaWWAN: -// case AFNetworkReachabilityStatusReachableViaWiFi: -// { -// if (self.isFirstReachability) { -// [[NSNotificationCenter defaultCenter] postNotificationName:kNetworkReachabilityKey object:nil userInfo:nil]; -// [self.presenter autoLogin]; -// [[ClientConfig shareConfig] clientInit]; -// } -// self.isFirstReachability = YES; -// } -// break; -// default: -// break; -// } -// }]; + // @kWeakify(self); + // [[AFNetworkReachabilityManager sharedManager] startMonitoring]; + // [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + // @kStrongify(self); + // switch (status) { + // case AFNetworkReachabilityStatusUnknown: + // self.isFirstReachability = YES; + // break; + // case AFNetworkReachabilityStatusNotReachable: + // self.isFirstReachability = YES; + // break; + // case AFNetworkReachabilityStatusReachableViaWWAN: + // case AFNetworkReachabilityStatusReachableViaWiFi: + // { + // if (self.isFirstReachability) { + // [[NSNotificationCenter defaultCenter] postNotificationName:kNetworkReachabilityKey object:nil userInfo:nil]; + // [self.presenter autoLogin]; + // [[ClientConfig shareConfig] clientInit]; + // } + // self.isFirstReachability = YES; + // } + // break; + // default: + // break; + // } + // }]; } #pragma mark - BaseMvpProtocol @@ -448,7 +479,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc]; nav.modalPresentationStyle = UIModalPresentationFullScreen; kWindow.rootViewController = nav; - XPAdImageTool.shareImageTool.isImLogin = NO; + XPAdImageTool.shareImageTool.isImLogin = NO; } - (void)completeUserInfo { @@ -481,12 +512,12 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; ///获取更新版本信息成功 - (void)getVersionUpdate:(XPVersionUpdateModel *)versionModel { - XPUpgradeView *view = [[XPUpgradeView alloc] init]; - view.versionModel = versionModel; - TTPopupService * service = [[TTPopupService alloc] init]; - service.contentView = view; - service.shouldDismissOnBackgroundTouch = NO; - [TTPopup popupWithConfig:service]; + XPUpgradeView *view = [[XPUpgradeView alloc] init]; + view.versionModel = versionModel; + TTPopupService * service = [[TTPopupService alloc] init]; + service.contentView = view; + service.shouldDismissOnBackgroundTouch = NO; + [TTPopup popupWithConfig:service]; } #pragma mark - NIMLoginManagerDelegate @@ -507,47 +538,47 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } - (void)onKickout:(NIMLoginKickoutResult *)result { - [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"TabbarViewController0")]; - UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; - if ([rootViewController presentedViewController]) { //有一个被present出来的控制器 要先dismiss - [[rootViewController presentedViewController] dismissViewControllerAnimated:YES completion:^{ - if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) { - [[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES]; - } - if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) { - UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController; - if (tabVC.selectedViewController.navigationController) { - [tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES]; - } - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [tabVC setSelectedIndex:0]; - }); - } - }]; - }else { //不是被present出来的 就有可能是rootvc或者是被push出来的 所以要判断nav是不是只有一个vc 如果有多个就pop - if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) { - [[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES]; - } - if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) { - UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController; - if (tabVC.selectedViewController) { - if ([tabVC.selectedViewController isKindOfClass:[UINavigationController class]]) { - [tabVC.selectedViewController popToRootViewControllerAnimated:YES]; - } else { - [tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES]; - } - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [tabVC setSelectedIndex:0]; - }); - } - } - } - - if ([XPRoomMiniManager shareManager].getRoomInfo) { - [[RtcManager instance] exitRoom]; - [[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil]; - [self.roomMineView hiddenRoomMiniView]; - } + [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"TabbarViewController0")]; + UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; + if ([rootViewController presentedViewController]) { //有一个被present出来的控制器 要先dismiss + [[rootViewController presentedViewController] dismissViewControllerAnimated:YES completion:^{ + if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) { + [[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES]; + } + if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) { + UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController; + if (tabVC.selectedViewController.navigationController) { + [tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES]; + } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [tabVC setSelectedIndex:0]; + }); + } + }]; + }else { //不是被present出来的 就有可能是rootvc或者是被push出来的 所以要判断nav是不是只有一个vc 如果有多个就pop + if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) { + [[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES]; + } + if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) { + UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController; + if (tabVC.selectedViewController) { + if ([tabVC.selectedViewController isKindOfClass:[UINavigationController class]]) { + [tabVC.selectedViewController popToRootViewControllerAnimated:YES]; + } else { + [tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES]; + } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [tabVC setSelectedIndex:0]; + }); + } + } + } + + if ([XPRoomMiniManager shareManager].getRoomInfo) { + [[RtcManager instance] exitRoom]; + [[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil]; + [self.roomMineView hiddenRoomMiniView]; + } [self.presenter logout]; } @@ -557,57 +588,57 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; if (![ClientConfig shareConfig].canOpen || [AccountInfoStorage instance].getTicket.length == 0) { return; } - for (NIMMessage * message in messages) { - if (message.session.sessionType == NIMSessionTypeP2P) { - if(message.messageType == NIMMessageTypeCustom) { - NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; - if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { - AttachmentModel * attachment = (AttachmentModel *)obj.attachment; - if (attachment.first == CustomMessageType_FindNew && attachment.second == Custom_Message_Find_New_Greet_New_User) { - FindNewGreetMessageModel * greetInfo = [FindNewGreetMessageModel modelWithDictionary:attachment.data]; - if (greetInfo.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) { - [TTPopup dismiss]; - XPSessionFindNewAlertView * alertView = [[XPSessionFindNewAlertView alloc] init]; - alertView.userInfo = greetInfo; - TTPopupService *service = [[TTPopupService alloc] init]; - service.contentView = alertView; - service.shouldDismissOnBackgroundTouch = NO; - service.style = TTPopupStyleAlert; - [TTPopup popupWithConfig:service]; - } + for (NIMMessage * message in messages) { + if (message.session.sessionType == NIMSessionTypeP2P) { + if(message.messageType == NIMMessageTypeCustom) { + NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; + if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { + AttachmentModel * attachment = (AttachmentModel *)obj.attachment; + if (attachment.first == CustomMessageType_FindNew && attachment.second == Custom_Message_Find_New_Greet_New_User) { + FindNewGreetMessageModel * greetInfo = [FindNewGreetMessageModel modelWithDictionary:attachment.data]; + if (greetInfo.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) { + [TTPopup dismiss]; + XPSessionFindNewAlertView * alertView = [[XPSessionFindNewAlertView alloc] init]; + alertView.userInfo = greetInfo; + TTPopupService *service = [[TTPopupService alloc] init]; + service.contentView = alertView; + service.shouldDismissOnBackgroundTouch = NO; + service.style = TTPopupStyleAlert; + [TTPopup popupWithConfig:service]; + } } - } - } + } + } } - } + } } - (void)onReceiveBroadcastMessage:(NIMBroadcastMessage *)broadcastMessage { - if (![ClientConfig shareConfig].canOpen || [AccountInfoStorage instance].getUid.length == 0) { - return; - } - if (broadcastMessage.content) { - NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject]; - AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]]; + if (![ClientConfig shareConfig].canOpen || [AccountInfoStorage instance].getUid.length == 0) { + return; + } + if (broadcastMessage.content) { + NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject]; + AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]]; NSString *partitionId = [NSString stringWithFormat:@"%@",attachment.data[@"partitionId"]]; if(![partitionId isEqualToString:self.userInfo.partitionId]){ return; } - if (attachment.first == CustomMessageType_RedPacket) { + if (attachment.first == CustomMessageType_RedPacket) { [self receiveRedPacketDealWithData:attachment]; - } else if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广播 年度飘屏 - [self receiveBroadcastGift:attachment]; - }else if(attachment.first == CustomMessageType_Version_Update && attachment.second == Custom_Message_Version_Update_Value){ - NSString *osValue = attachment.data[@"updateOs"]; - if([osValue isEqualToString:@"ios"] && [AccountInfoStorage instance].getUid.length > 0){ - XPVersionUpdateModel *updateModel = [XPVersionUpdateModel modelWithDictionary:attachment.data]; - [self getVersionUpdate:updateModel]; - } + } else if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广播 年度飘屏 + [self receiveBroadcastGift:attachment]; + }else if(attachment.first == CustomMessageType_Version_Update && attachment.second == Custom_Message_Version_Update_Value){ + NSString *osValue = attachment.data[@"updateOs"]; + if([osValue isEqualToString:@"ios"] && [AccountInfoStorage instance].getUid.length > 0){ + XPVersionUpdateModel *updateModel = [XPVersionUpdateModel modelWithDictionary:attachment.data]; + [self getVersionUpdate:updateModel]; + } }else if(attachment.first == CustomMessageType_LuckyBag && attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree){ - + if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; [self.roomAnimation receiveLuckyGiftBigPrize:attachment]; }else if(attachment.first == CustomMessageType_Graffiti_Star_Kitchen && attachment.second == Custom_Message_Sub_Star_Kitchen_FullScreen){ @@ -632,14 +663,14 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; [self.roomAnimation receiveAnchorHourRank:attachment]; }else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Noble_LevelUp_Suspend) {///VIP升级全服飘屏 - if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; + if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; [self.roomAnimation receiveNobleLevelUp:attachment]; }else if (attachment.first == CustomMessageType_General_Floating_Screen && attachment.second == Custom_Message_Sub_General_Floating_Screen_All_Room){ if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; [self.roomAnimation receiveRoomGeneralFloatingScreen:attachment]; } - } + } } ///收到红包,处理数据 -(void)receiveRedPacketDealWithData:(AttachmentModel *)attachment{ @@ -651,7 +682,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; //判断是否在房间 __block BOOL isInRoom; - + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj isKindOfClass:[XPRoomViewController class]]) { *stop = YES; @@ -686,15 +717,15 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; * @discusssion 云信在收到消息撤回后,会先从本地数据库中找到对应消息并进行删除,之后通知上层消息已删除 */ - (void)onRecvRevokeMessageNotification:(NIMRevokeMessageNotification *)notification { - NIMMessage * message = notification.message; - if (message) { - NIMMessage * revokeMessage = [[NIMMessage alloc] init]; - [revokeMessage setValue:message.session forKey:@"session"]; - [revokeMessage setValue:@(NIMMessageTypeTip) forKey:@"messageType"]; - revokeMessage.timestamp = [PLTimeUtil getNowTimeTimestampMillisecond].longLongValue; - revokeMessage.text = YMLocalizedString(@"TabbarViewController1"); - [[NIMSDK sharedSDK].conversationManager saveMessage:revokeMessage forSession:message.session completion:nil]; - } + NIMMessage * message = notification.message; + if (message) { + NIMMessage * revokeMessage = [[NIMMessage alloc] init]; + [revokeMessage setValue:message.session forKey:@"session"]; + [revokeMessage setValue:@(NIMMessageTypeTip) forKey:@"messageType"]; + revokeMessage.timestamp = [PLTimeUtil getNowTimeTimestampMillisecond].longLongValue; + revokeMessage.text = YMLocalizedString(@"TabbarViewController1"); + [[NIMSDK sharedSDK].conversationManager saveMessage:revokeMessage forSession:message.session completion:nil]; + } } - (void)configTheme { @@ -707,23 +738,23 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } - (void)initTabs:(BOOL)logined { - self.viewControllers = nil; - NSArray *normalImageNames = @[@"tab_gameHome_normal",@"tab_monents_normal",@"tab_message_normal", @"tab_mine_normal"]; - NSArray *selectImageNames = @[@"tab_gameHome_selected",@"tab_monents_select",@"tab_message_selected", @"tab_mine_selected"]; - NSArray *tabLabel = @[YMLocalizedString(@"TabbarViewController2"),YMLocalizedString(@"TabbarViewController3"),YMLocalizedString(@"TabbarViewController4"), YMLocalizedString(@"TabbarViewController5")]; + self.viewControllers = nil; + NSArray *normalImageNames = @[@"tab_gameHome_normal",@"tab_monents_normal",@"tab_message_normal", @"tab_mine_normal"]; + NSArray *selectImageNames = @[@"tab_gameHome_selected",@"tab_monents_select",@"tab_message_selected", @"tab_mine_selected"]; + NSArray *tabLabel = @[YMLocalizedString(@"TabbarViewController2"),YMLocalizedString(@"TabbarViewController3"),YMLocalizedString(@"TabbarViewController4"), YMLocalizedString(@"TabbarViewController5")]; UIViewController *game; UIViewController *msg; UIViewController *me; - UIViewController * home; - UIViewController * monents; + UIViewController * home; + UIViewController * monents; ///取消检查ip定时器,释放XPNewHomeViewController [[NSNotificationCenter defaultCenter]postNotificationName:@"kInLoginVC" object:nil]; if (logined) { msg = [[XPSessionMainViewController alloc] init]; if ([ClientConfig shareConfig].canOpen) { - + home = [[XPNewHomeViewController alloc] init]; monents = [[XPMonentsViewController alloc] init]; me = [[XPMineViewController alloc] init]; @@ -736,12 +767,12 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; game = [[XPBlankViewController alloc]init]; msg = [[XPSessionMainViewController alloc]init]; me = [[XPBlankViewController alloc]init]; - home = [[XPBlankViewController alloc] init]; - monents = [[XPBlankViewController alloc] init]; + home = [[XPBlankViewController alloc] init]; + monents = [[XPBlankViewController alloc] init]; } - [self createTabBarItem:home title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]]; - [self createTabBarItem:monents title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]]; - [self createTabBarItem:msg title:tabLabel[2] image:normalImageNames[2] selectedImage:selectImageNames[2]]; + [self createTabBarItem:home title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]]; + [self createTabBarItem:monents title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]]; + [self createTabBarItem:msg title:tabLabel[2] image:normalImageNames[2] selectedImage:selectImageNames[2]]; [self createTabBarItem:me title:tabLabel[3] image:normalImageNames[3] selectedImage:selectImageNames[3]]; self.viewControllers = @[home,monents,msg,me]; self.selectedIndex = 0; @@ -775,18 +806,18 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; #pragma mark - 动态 - (void)monentsUnReadCount { - [Api monentsUnReadCount:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - MonentsUnReadModel * model = [MonentsUnReadModel modelWithDictionary:data.data]; - NSString *badge = model.total > 0 ? @(model.total).stringValue : nil; - if (model.total > 99) { - badge = @"99+"; - } - NSUInteger index = 1; - UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; - [item setBadgeValue:badge]; - } - } uid:[AccountInfoStorage instance].getUid]; + [Api monentsUnReadCount:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + MonentsUnReadModel * model = [MonentsUnReadModel modelWithDictionary:data.data]; + NSString *badge = model.total > 0 ? @(model.total).stringValue : nil; + if (model.total > 99) { + badge = @"99+"; + } + NSUInteger index = 1; + UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; + [item setBadgeValue:badge]; + } + } uid:[AccountInfoStorage instance].getUid]; NSArray *recentList = [[NIMSDK sharedSDK].conversationManager.allRecentSessions mutableCopy]; __block NSInteger unreadCount = 0; NSMutableArray * uids = [[NSMutableArray alloc] init]; @@ -794,34 +825,34 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; [uids addObject:obj.session.sessionId]; unreadCount += obj.unreadCount; }]; - if(unreadCount > 0){ - NSUInteger index = 2; - UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; - [item setBadgeValue:[NSString stringWithFormat:@"%ld",unreadCount]]; - } + if(unreadCount > 0){ + NSUInteger index = 2; + UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; + [item setBadgeValue:[NSString stringWithFormat:@"%ld",unreadCount]]; + } } #pragma mark - 房间最小化 - (void)configRoomMiniNView:(NSDictionary *)dic { - UserInfoModel * userInfo = [UserInfoModel modelWithDictionary:dic[@"userInfo"]]; - RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic[@"roomInfo"]]; - NSMutableDictionary * microQueue = dic[@"microQueue"]; - [self.roomMineView configRoomMiniView:roomInfo userInfo:userInfo micQueue:microQueue]; + UserInfoModel * userInfo = [UserInfoModel modelWithDictionary:dic[@"userInfo"]]; + RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic[@"roomInfo"]]; + NSMutableDictionary * microQueue = dic[@"microQueue"]; + [self.roomMineView configRoomMiniView:roomInfo userInfo:userInfo micQueue:microQueue]; } #pragma mark - 快捷进房 - (void)initQuickEnterRoom { - NSString * key = [NSString stringWithFormat:@"%@_%@", kUserFirstLoginKey, [AccountInfoStorage instance].getUid]; - BOOL isNotFirstLogin = [[NSUserDefaults standardUserDefaults] boolForKey:key]; - if (!isNotFirstLogin) { - ///新用户 -// [self.presenter getNewUserGreetInfo]; - } + NSString * key = [NSString stringWithFormat:@"%@_%@", kUserFirstLoginKey, [AccountInfoStorage instance].getUid]; + BOOL isNotFirstLogin = [[NSUserDefaults standardUserDefaults] boolForKey:key]; + if (!isNotFirstLogin) { + ///新用户 + // [self.presenter getNewUserGreetInfo]; + } } ///跳转优先级 闪屏→linkedMe→邀请码→新用户打招呼引导→渠道指定房间 - (void)completeUserInfoFinish:(NSString *)inviteCode { - self.inviteCode = inviteCode; + self.inviteCode = inviteCode; } #pragma mark -NIMSystemNotificationManagerDelegate - (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification { @@ -960,98 +991,98 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } - (void)handleAnchorCardSwipeFrom:(UISwipeGestureRecognizer *)recognizer{ - if(recognizer.direction == UISwipeGestureRecognizerDirectionUp) { - [UIView animateWithDuration:0.5 animations:^{ - self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90); - } completion:^(BOOL finished) { - [self.anchorCardView removeFromSuperview]; - self.anchorCardView = nil; - self.needShowAnchorCard = NO; - }]; - } + if(recognizer.direction == UISwipeGestureRecognizerDirectionUp) { + [UIView animateWithDuration:0.5 animations:^{ + self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90); + } completion:^(BOOL finished) { + [self.anchorCardView removeFromSuperview]; + self.anchorCardView = nil; + self.needShowAnchorCard = NO; + }]; + } } #pragma mark - 年度礼物飘屏 - (void)receiveBroadcastGift:(AttachmentModel *)attachment { GiftReceiveInfoModel *giftNotifyInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data]; - if (!giftNotifyInfo.ceremonyGift && giftNotifyInfo.isHomeShow == YES) { - if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; + if (!giftNotifyInfo.ceremonyGift && giftNotifyInfo.isHomeShow == YES) { + if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; [self.roomAnimation receiveGift:giftNotifyInfo]; - return; - } + return; + } if(giftNotifyInfo.isHomeShow == NO)return; - if (self.giftBroadcastQueue.count == 0) { - [self createGiftBroadcastViewAnimation:giftNotifyInfo]; - } - [self.giftBroadcastQueue addObject:giftNotifyInfo]; + if (self.giftBroadcastQueue.count == 0) { + [self createGiftBroadcastViewAnimation:giftNotifyInfo]; + } + [self.giftBroadcastQueue addObject:giftNotifyInfo]; } - (void)createGiftBroadcastViewAnimation:(GiftReceiveInfoModel *)giftModel { - XPRoomYearActivityView * view = [[XPRoomYearActivityView alloc] init]; - view.delegate = self; - view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, 150); - view.model = giftModel; - [[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:view]; - [self beginGiftBraodcastViewAnimation:view notifyStaySecond:giftModel.notifyStaySecond]; + XPRoomYearActivityView * view = [[XPRoomYearActivityView alloc] init]; + view.delegate = self; + view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, 150); + view.model = giftModel; + [[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:view]; + [self beginGiftBraodcastViewAnimation:view notifyStaySecond:giftModel.notifyStaySecond]; } - (void)beginGiftBraodcastViewAnimation:(XPRoomYearActivityView *)view notifyStaySecond:(int)notifyStaySecond{ - CGFloat startTime = notifyStaySecond > 0 ? notifyStaySecond : 3.0; - POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; - springAnimation.springSpeed = 12; - springAnimation.springBounciness = 10.f; - springAnimation.fromValue = [NSValue valueWithCGPoint:view.center]; - springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0 + view.frame.size.width / 2, view.center.y)]; - [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { - if (finished) { - [self removeGiftBroadcastOutAnimation:view stayTime:startTime]; - } - }]; - [view pop_addAnimation:springAnimation forKey:@"spingOutAnimation"]; + CGFloat startTime = notifyStaySecond > 0 ? notifyStaySecond : 3.0; + POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; + springAnimation.springSpeed = 12; + springAnimation.springBounciness = 10.f; + springAnimation.fromValue = [NSValue valueWithCGPoint:view.center]; + springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0 + view.frame.size.width / 2, view.center.y)]; + [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { + if (finished) { + [self removeGiftBroadcastOutAnimation:view stayTime:startTime]; + } + }]; + [view pop_addAnimation:springAnimation forKey:@"spingOutAnimation"]; } - (void)removeGiftBroadcastOutAnimation:(XPRoomYearActivityView *)view stayTime:(CGFloat)stayTime{ - POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; - moveAnimation.fromValue = [NSValue valueWithCGPoint:view.center]; - moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, view.center.y)]; - moveAnimation.beginTime = CACurrentMediaTime() + stayTime; - moveAnimation.duration = 0.5; - moveAnimation.repeatCount = 1; - moveAnimation.removedOnCompletion = YES; - @kWeakify(self); - [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { - @kStrongify(self); - if (finished) { - [view removeFromSuperview]; - if (self.giftBroadcastQueue.count > 0) { - [self.giftBroadcastQueue removeObjectAtIndex:0]; - } - if (self.giftBroadcastQueue.count > 0) { - [self createGiftBroadcastViewAnimation:self.giftBroadcastQueue.firstObject]; - } - } - }]; - - [view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; + moveAnimation.fromValue = [NSValue valueWithCGPoint:view.center]; + moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, view.center.y)]; + moveAnimation.beginTime = CACurrentMediaTime() + stayTime; + moveAnimation.duration = 0.5; + moveAnimation.repeatCount = 1; + moveAnimation.removedOnCompletion = YES; + @kWeakify(self); + [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { + @kStrongify(self); + if (finished) { + [view removeFromSuperview]; + if (self.giftBroadcastQueue.count > 0) { + [self.giftBroadcastQueue removeObjectAtIndex:0]; + } + if (self.giftBroadcastQueue.count > 0) { + [self createGiftBroadcastViewAnimation:self.giftBroadcastQueue.firstObject]; + } + } + }]; + + [view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; } #pragma mark - XPRoomGiftBroadcastViewDelegate - (void)xPRoomYearActivityViewEnterRoom:(NSString *)roomUid{ - if (roomUid.length > 0) { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; - }); - } + if (roomUid.length > 0) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } } #pragma mark - Getters And Setters - (XPMiniRoomView *)roomMineView { - if (!_roomMineView) { - _roomMineView = [[XPMiniRoomView alloc] init]; - _roomMineView.controller = self; - _roomMineView.hidden = YES; - } - return _roomMineView; + if (!_roomMineView) { + _roomMineView = [[XPMiniRoomView alloc] init]; + _roomMineView.controller = self; + _roomMineView.hidden = YES; + } + return _roomMineView; } - (XPAnchorCardView *)anchorCardView { @@ -1071,10 +1102,10 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } - (NSMutableArray *)giftBroadcastQueue { - if (!_giftBroadcastQueue) { - _giftBroadcastQueue = [NSMutableArray array]; - } - return _giftBroadcastQueue; + if (!_giftBroadcastQueue) { + _giftBroadcastQueue = [NSMutableArray array]; + } + return _giftBroadcastQueue; } - (PIFullScreenBannerAnimation *)roomAnimation{ if(!_roomAnimation){ diff --git a/YuMi/Tools/File/UploadFile.m b/YuMi/Tools/File/UploadFile.m index 481e9189..1c909f79 100644 --- a/YuMi/Tools/File/UploadFile.m +++ b/YuMi/Tools/File/UploadFile.m @@ -260,7 +260,8 @@ static UploadFile* manager; } +(void)downloadAudioWithFileName:(NSString *)fileName musicUrl:(NSString *)musicUrl mainFileName:(NSString *)mainFileName completion:(void (^) (BOOL isSuccess, NSString *editAudioPath))completion { AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; - NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:musicUrl]]; + NSURL *url = [NSURL URLWithString:[musicUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]]; + NSURLRequest *request = [NSURLRequest requestWithURL :url]; NSURLSessionDownloadTask *download = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) { } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:mainFileName] stringByAppendingPathComponent:fileName]; diff --git a/YuMi/en.lproj/Localizable.strings b/YuMi/en.lproj/Localizable.strings index 31aa74b7..4babc776 100644 --- a/YuMi/en.lproj/Localizable.strings +++ b/YuMi/en.lproj/Localizable.strings @@ -164,8 +164,8 @@ "PKIDLoginViewController2" = "Please contact customer service"; "PKIDLoginViewController3" = "LINE:pekoyuyin"; "PKIDLoginViewController4" = "I understand"; -"MessageLevelUpgradeModel0" = "Congratulations! Your charm level has reached Lv%@"; -"MessageLevelUpgradeModel1" = "Congratulations! Your level has reached Lv%@"; +"MessageLevelUpgradeModel0" = "Congratulations! Your charm level has reached %@"; +"MessageLevelUpgradeModel1" = "Congratulations! Your level has reached %@"; "MessageTextModel0" = "Unknown message type"; diff --git a/YuMi/zh-Hans.lproj/Localizable.strings b/YuMi/zh-Hans.lproj/Localizable.strings index b6e7b6cc..5eb8a650 100644 --- a/YuMi/zh-Hans.lproj/Localizable.strings +++ b/YuMi/zh-Hans.lproj/Localizable.strings @@ -1962,8 +1962,8 @@ "PKIDLoginViewController2" = "请联繫客服处理"; "PKIDLoginViewController3" = "LINE:pekoyuyin"; "PKIDLoginViewController4" = "我知道了"; -"MessageLevelUpgradeModel0" = "恭喜!您的魅力等级已到达Lv%@"; -"MessageLevelUpgradeModel1" = "恭喜!您的等级已到达Lv%@"; +"MessageLevelUpgradeModel0" = "恭喜!您的魅力等级已到达%@"; +"MessageLevelUpgradeModel1" = "恭喜!您的等级已到达%@"; "MessageTextModel0" = "未知消息类型"; diff --git a/YuMi/zh-Hant.lproj/Localizable.strings b/YuMi/zh-Hant.lproj/Localizable.strings index 2ba0033e..4d2199cb 100644 --- a/YuMi/zh-Hant.lproj/Localizable.strings +++ b/YuMi/zh-Hant.lproj/Localizable.strings @@ -1957,8 +1957,8 @@ "PKIDLoginViewController2" = "請聯繫客服處理"; "PKIDLoginViewController3" = "LINE:pekoyuyin"; "PKIDLoginViewController4" = "我知道了"; -"MessageLevelUpgradeModel0" = "恭喜!您的魅力等級已到達Lv%@"; -"MessageLevelUpgradeModel1" = "恭喜!您的等級已到達Lv%@"; +"MessageLevelUpgradeModel0" = "恭喜!您的魅力等級已到達%@"; +"MessageLevelUpgradeModel1" = "恭喜!您的等級已到達%@"; "MessageTextModel0" = "未知消息類型";