礼物动效缓存

This commit is contained in:
liyuhua
2024-05-15 17:35:51 +08:00
parent e47967a1e6
commit 1723782767
12 changed files with 379 additions and 331 deletions

View File

@@ -575,6 +575,9 @@
[self.messages removeObjectsInArray:needRemoveMsgArray]; [self.messages removeObjectsInArray:needRemoveMsgArray];
} }
for (NIMMessage *message in messages) { for (NIMMessage *message in messages) {
if (![self isCanAddMsg:message]){
return;
}
[self addTimeMessage:message]; [self addTimeMessage:message];
if (message.isDeleted) { if (message.isDeleted) {
continue; continue;
@@ -599,7 +602,11 @@
if (message.session.sessionType != NIMSessionTypeChatroom) { if (message.session.sessionType != NIMSessionTypeChatroom) {
return; return;
} }
if (![self isCanAddMsg:message]){
return;
}
[self addTimeMessage:message]; [self addTimeMessage:message];
if (![self isExistMessages:message]) { if (![self isExistMessages:message]) {
if ([self isCanAddMsg:message]){ if ([self isCanAddMsg:message]){
[self addTimeMessage:message]; [self addTimeMessage:message];

View File

@@ -2053,11 +2053,11 @@
/// SVGA /// SVGA
- (void)playGiftEffect:(NSString *)vggUrl { - (void)playGiftEffect:(NSString *)vggUrl {
if ([self isInSudGame]) {return;} if ([self isInSudGame]) {return;}
NSString *baseFileName = @"/GiftSvga"; NSString *fileName = [[vggUrl componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vggUrl]; NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([fileManager fileExistsAtPath:filePath]){ if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
NSData *data=[NSData dataWithContentsOfFile:filePath options:0 error:NULL]; NSData *data=[NSData dataWithContentsOfFile:fullPath options:0 error:NULL];
[self.parser parseWithData:data cacheKey:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { [self.parser parseWithData:data cacheKey:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
if (videoItem != nil) { if (videoItem != nil) {
@@ -2161,11 +2161,11 @@
/// vap /// vap
- (void)playGiftEffectWithVapUrl:(NSString *)vapUrl { - (void)playGiftEffectWithVapUrl:(NSString *)vapUrl {
NSString *baseFileName = @"/GiftMp4"; NSString *fileName = [[vapUrl componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vapUrl]; NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([fileManager fileExistsAtPath:filePath]){ if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
vapUrl = filePath; vapUrl = fullPath;
self.vapGiftEffectView.hidden = NO; self.vapGiftEffectView.hidden = NO;
if (self.vapGiftEffectView.superview == nil) { if (self.vapGiftEffectView.superview == nil) {
@@ -2205,11 +2205,11 @@
if ([self isInSudGame]) {return;} if ([self isInSudGame]) {return;}
NSString *baseFileName = @"/GiftSvga"; NSString *fileName = [[vggUrl.absoluteString componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vggUrl.absoluteString]; NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([fileManager fileExistsAtPath:filePath]){ if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
NSData *data=[NSData dataWithContentsOfFile:filePath options:0 error:NULL]; NSData *data=[NSData dataWithContentsOfFile:fullPath options:0 error:NULL];
[self.parser parseWithData:data cacheKey:@"" completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { [self.parser parseWithData:data cacheKey:@"" completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
if (videoItem != nil) { if (videoItem != nil) {
self.luckyGiftEffectView.hidden = NO; self.luckyGiftEffectView.hidden = NO;
@@ -2284,11 +2284,11 @@
/// vap /// vap
- (void)playLuckyGiftEffectWithVapUrl:(NSString *)vapUrl { - (void)playLuckyGiftEffectWithVapUrl:(NSString *)vapUrl {
NSString *baseFileName = @"/GiftMp4"; NSString *fileName = [[vapUrl componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:vapUrl]; NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([fileManager fileExistsAtPath:filePath]){ if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
vapUrl = filePath; vapUrl = fullPath;
self.luckyVapGiftEffectView.hidden = NO; self.luckyVapGiftEffectView.hidden = NO;
if (self.luckyVapGiftEffectView.superview == nil) { if (self.luckyVapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.luckyVapGiftEffectView]; [self.middleLevelView addSubview:self.luckyVapGiftEffectView];

View File

@@ -77,8 +77,10 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)requestTwelveStarFirst:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid; + (void)requestTwelveStarFirst:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid;
/// 请求缓存列表 /// 请求缓存列表
/// @param complection 完成 /// @param complection 完成
/// @param roomUid 房间的roomuid
+ (void)requestCacheGiftList:(HttpRequestHelperCompletion)complection; + (void)requestCacheGiftList:(HttpRequestHelperCompletion)complection;
/// 请求新礼物动效缓存列表
/// @param complection 完成
+(void)requestCacheGiftDynamicEffectList:(HttpRequestHelperCompletion)complection;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -32,6 +32,12 @@
NSString * fang = @"gift/vgg"; NSString * fang = @"gift/vgg";
[self makeRequest:fang method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, nil]; [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 /// @param complection
+ (void)requestLuckGiftServerBagRecord:(HttpRequestHelperCompletion)complection { + (void)requestLuckGiftServerBagRecord:(HttpRequestHelperCompletion)complection {

View File

@@ -190,10 +190,11 @@
if(meQuence != nil){ if(meQuence != nil){
[self enterRoomUpMicWith:meQuence]; [self enterRoomUpMicWith:meQuence];
} }
//
[self initGiftValue];
}]; }];
//
[self initGiftValue];
} }
/// ///
-(void)enterRoomUpMicWith:(MicroQueueModel *)sequence{ -(void)enterRoomUpMicWith:(MicroQueueModel *)sequence{

View File

@@ -480,12 +480,12 @@
make.edges.mas_equalTo(self.forestImageView); make.edges.mas_equalTo(self.forestImageView);
}]; }];
NSString *baseFileName = @"/GiftMp4"; NSString *fileName = [[animtionName componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:animtionName]; NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([fileManager fileExistsAtPath:filePath]){ if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
[view setMute:YES]; [view setMute:YES];
[view playHWDMP4:filePath repeatCount:1 delegate:self]; [view playHWDMP4:fullPath repeatCount:1 delegate:self];
}else{ }else{
[self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) { [self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) {

View File

@@ -284,12 +284,12 @@
make.edges.equalTo(self.trialsBgImageView); make.edges.equalTo(self.trialsBgImageView);
}]; }];
} }
NSString *baseFileName = @"/GiftMp4"; NSString *fileName = [[animtionName componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:animtionName]; NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([fileManager fileExistsAtPath:filePath]){ if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
[self.trialsView setMute:YES]; [self.trialsView setMute:YES];
[self.trialsView playHWDMP4:filePath repeatCount:1 delegate:self]; [self.trialsView playHWDMP4:fullPath repeatCount:1 delegate:self];
}else{ }else{
[self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) { [self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) {

View File

@@ -96,7 +96,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate,XPLoginAuthCodeVCDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate, XPRoomYearActivityViewDelegate> @interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate,XPLoginAuthCodeVCDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate, XPRoomYearActivityViewDelegate>
{ {
NSTimer * timer; NSTimer * timer;
} }
/// ///
@property (nonatomic,strong) UserInfoModel *userInfo; @property (nonatomic,strong) UserInfoModel *userInfo;
@@ -138,7 +138,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
} }
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self.presenter autoLogin]; [self.presenter autoLogin];
[self configTheme]; [self configTheme];
@@ -151,7 +151,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[[NIMSDK sharedSDK].chatManager addDelegate:self]; [[NIMSDK sharedSDK].chatManager addDelegate:self];
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self]; [[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
[[NIMSDK sharedSDK].broadcastManager addDelegate:self]; [[NIMSDK sharedSDK].broadcastManager addDelegate:self];
[self networkReachability]; [self networkReachability];
[self.view addSubview:self.roomMineView]; [self.view addSubview:self.roomMineView];
@kWeakify(self); @kWeakify(self);
@@ -159,8 +159,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
@kStrongify(self); @kStrongify(self);
[self configRoomMiniNView:note.userInfo]; [self configRoomMiniNView:note.userInfo];
}]; }];
[[NSNotificationCenter defaultCenter] addObserverForName:@"reloadnewtab" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [[NSNotificationCenter defaultCenter] addObserverForName:@"reloadnewtab" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
@kStrongify(self); @kStrongify(self);
if (self.isInitReload == NO) { 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(showNewUserRecharge) name:kNewUserRechargeKey object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage:) name:@"kSwitchLanguage" object:nil]; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage:) name:@"kSwitchLanguage" object:nil];
} }
-(void)switchLanguage:(NSNotification *)not{ -(void)switchLanguage:(NSNotification *)not{
[self initTabs:YES]; [self initTabs:YES];
@@ -288,10 +288,10 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
self.inviteCode = nil; self.inviteCode = nil;
} }
[self monentsUnReadCount]; [self monentsUnReadCount];
} }
} }
-(void)loginIng{ -(void)loginIng{
if ((self.userInfo.nick == nil || self.userInfo.avatar == nil) && self.isFormLogin == NO) { if ((self.userInfo.nick == nil || self.userInfo.avatar == nil) && self.isFormLogin == NO) {
@@ -310,7 +310,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
self.inviteCode = nil; self.inviteCode = nil;
} }
[self monentsUnReadCount]; [self monentsUnReadCount];
} }
} }
- (void)getAuthorizationCodeInfoWithPhonefail{ - (void)getAuthorizationCodeInfoWithPhonefail{
@@ -336,39 +336,50 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
/// ///
-(void)requestGiftList{ -(void)requestGiftList{
[self dealWithDefaultSvga]; [self dealWithDefaultSvga];
/// ///
NSString *time = [NSDate getNowTimeTimestamp]; // NSString *time = [NSDate getNowTimeTimestamp];
NSString *curTime = [NSDate timestampSwitchTime:[time integerValue] andFormatter:@"yyyy-MM-dd"]; // NSString *curTime = [NSDate timestampSwitchTime:[time integerValue] andFormatter:@"yyyy-MM-dd"];
NSDictionary *timeDic = [[NSUserDefaults standardUserDefaults]valueForKey:@"kRequestGiftList"]; // NSDictionary *timeDic = [[NSUserDefaults standardUserDefaults]valueForKey:@"kRequestGiftList"];
if(timeDic == nil){ // if(timeDic == nil){
NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic]; // NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic];
[curDic setValue:@(YES) forKey:curTime]; // [curDic setValue:@(YES) forKey:curTime];
[[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"]; // [[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"];
[[NSUserDefaults standardUserDefaults]synchronize]; // [[NSUserDefaults standardUserDefaults]synchronize];
}else{ // }else{
if(timeDic[curTime]!= nil)return; // if(timeDic[curTime]!= nil)return;
NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic]; // NSMutableDictionary *curDic = [[NSMutableDictionary alloc]initWithDictionary:timeDic];
[curDic removeAllObjects]; // [curDic removeAllObjects];
[curDic setValue:@(YES) forKey:curTime]; // [curDic setValue:@(YES) forKey:curTime];
[[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"]; // [[NSUserDefaults standardUserDefaults]setValue:curDic forKey:@"kRequestGiftList"];
[[NSUserDefaults standardUserDefaults]synchronize]; // [[NSUserDefaults standardUserDefaults]synchronize];
} // }
[Api requestCacheGiftList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { [Api requestCacheGiftList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){ if(code == 200){
NSArray *giftList = [GiftInfoModel modelsWithArray:data.data]; NSArray *giftList = [GiftInfoModel modelsWithArray:data.data];
for (GiftInfoModel *giftModel in giftList) { for (GiftInfoModel *giftModel in giftList) {
if(giftModel.vggUrl.length > 0){ 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){ }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{ -(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"]; 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) { 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"; -(void)cacheGiftDynamicEffectList:(NSString *)url{
NSString *filePaths = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:baseFileName] stringByAppendingPathComponent:fileName];
NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *fileName = [[url componentsSeparatedByString:@"/"] lastObject];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePaths])return; NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
[[[NSURLSession sharedSession] downloadTaskWithURL:[NSURL URLWithString:url] completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) { NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if(!error){ if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
[fileManager createDirectoryAtPath:[filePaths stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:nil]; return;
NSData *data = [NSData dataWithContentsOfURL:location]; }
[data writeToFile:filePaths atomically:YES]; 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 { - (void)checkInviteUserInfoSuccess:(InviteUserInfoModel *)inviteInfo {
if (inviteInfo && inviteInfo.isInRoom) { if (inviteInfo && inviteInfo.isInRoom) {
[XPRoomViewController openRoom:inviteInfo.roomUid fromNick:inviteInfo.inviteNick fromType:inviteInfo.fromType fromUid:inviteInfo.inviteUid viewController:self]; [XPRoomViewController openRoom:inviteInfo.roomUid fromNick:inviteInfo.inviteNick fromType:inviteInfo.fromType fromUid:inviteInfo.inviteUid viewController:self];
} else { // } else { //
[self.presenter getShortCutRecommendRoom]; [self.presenter getShortCutRecommendRoom];
} }
} }
- (void)getShortCutRecommendRoomSuccces:(NSString *)roomUid { - (void)getShortCutRecommendRoomSuccces:(NSString *)roomUid {
if (roomUid.length > 0) { if (roomUid.length > 0) {
[XPRoomViewController openRoom:roomUid viewController:self]; [XPRoomViewController openRoom:roomUid viewController:self];
} }
} }
#pragma mark - app #pragma mark - app
- (void)clientStartApp { - (void)clientStartApp {
// [self.presenter clientStartApp]; // [self.presenter clientStartApp];
} }
#pragma mark - #pragma mark -
- (void)networkReachability{ - (void)networkReachability{
// @kWeakify(self); // @kWeakify(self);
// [[AFNetworkReachabilityManager sharedManager] startMonitoring]; // [[AFNetworkReachabilityManager sharedManager] startMonitoring];
// [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { // [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
// @kStrongify(self); // @kStrongify(self);
// switch (status) { // switch (status) {
// case AFNetworkReachabilityStatusUnknown: // case AFNetworkReachabilityStatusUnknown:
// self.isFirstReachability = YES; // self.isFirstReachability = YES;
// break; // break;
// case AFNetworkReachabilityStatusNotReachable: // case AFNetworkReachabilityStatusNotReachable:
// self.isFirstReachability = YES; // self.isFirstReachability = YES;
// break; // break;
// case AFNetworkReachabilityStatusReachableViaWWAN: // case AFNetworkReachabilityStatusReachableViaWWAN:
// case AFNetworkReachabilityStatusReachableViaWiFi: // case AFNetworkReachabilityStatusReachableViaWiFi:
// { // {
// if (self.isFirstReachability) { // if (self.isFirstReachability) {
// [[NSNotificationCenter defaultCenter] postNotificationName:kNetworkReachabilityKey object:nil userInfo:nil]; // [[NSNotificationCenter defaultCenter] postNotificationName:kNetworkReachabilityKey object:nil userInfo:nil];
// [self.presenter autoLogin]; // [self.presenter autoLogin];
// [[ClientConfig shareConfig] clientInit]; // [[ClientConfig shareConfig] clientInit];
// } // }
// self.isFirstReachability = YES; // self.isFirstReachability = YES;
// } // }
// break; // break;
// default: // default:
// break; // break;
// } // }
// }]; // }];
} }
#pragma mark - BaseMvpProtocol #pragma mark - BaseMvpProtocol
@@ -448,7 +479,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc]; BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc];
nav.modalPresentationStyle = UIModalPresentationFullScreen; nav.modalPresentationStyle = UIModalPresentationFullScreen;
kWindow.rootViewController = nav; kWindow.rootViewController = nav;
XPAdImageTool.shareImageTool.isImLogin = NO; XPAdImageTool.shareImageTool.isImLogin = NO;
} }
- (void)completeUserInfo { - (void)completeUserInfo {
@@ -481,12 +512,12 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
/// ///
- (void)getVersionUpdate:(XPVersionUpdateModel *)versionModel { - (void)getVersionUpdate:(XPVersionUpdateModel *)versionModel {
XPUpgradeView *view = [[XPUpgradeView alloc] init]; XPUpgradeView *view = [[XPUpgradeView alloc] init];
view.versionModel = versionModel; view.versionModel = versionModel;
TTPopupService * service = [[TTPopupService alloc] init]; TTPopupService * service = [[TTPopupService alloc] init];
service.contentView = view; service.contentView = view;
service.shouldDismissOnBackgroundTouch = NO; service.shouldDismissOnBackgroundTouch = NO;
[TTPopup popupWithConfig:service]; [TTPopup popupWithConfig:service];
} }
#pragma mark - NIMLoginManagerDelegate #pragma mark - NIMLoginManagerDelegate
@@ -507,47 +538,47 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
} }
- (void)onKickout:(NIMLoginKickoutResult *)result { - (void)onKickout:(NIMLoginKickoutResult *)result {
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"TabbarViewController0")]; [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"TabbarViewController0")];
UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
if ([rootViewController presentedViewController]) { //present dismiss if ([rootViewController presentedViewController]) { //present dismiss
[[rootViewController presentedViewController] dismissViewControllerAnimated:YES completion:^{ [[rootViewController presentedViewController] dismissViewControllerAnimated:YES completion:^{
if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) { if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) {
[[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES]; [[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
} }
if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) { if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController; UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
if (tabVC.selectedViewController.navigationController) { if (tabVC.selectedViewController.navigationController) {
[tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES]; [tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES];
} }
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[tabVC setSelectedIndex:0]; [tabVC setSelectedIndex:0];
}); });
} }
}]; }];
}else { //present rootvcpush navvc pop }else { //present rootvcpush navvc pop
if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) { if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) {
[[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES]; [[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
} }
if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) { if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController; UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
if (tabVC.selectedViewController) { if (tabVC.selectedViewController) {
if ([tabVC.selectedViewController isKindOfClass:[UINavigationController class]]) { if ([tabVC.selectedViewController isKindOfClass:[UINavigationController class]]) {
[tabVC.selectedViewController popToRootViewControllerAnimated:YES]; [tabVC.selectedViewController popToRootViewControllerAnimated:YES];
} else { } else {
[tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES]; [tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES];
} }
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[tabVC setSelectedIndex:0]; [tabVC setSelectedIndex:0];
}); });
} }
} }
} }
if ([XPRoomMiniManager shareManager].getRoomInfo) { if ([XPRoomMiniManager shareManager].getRoomInfo) {
[[RtcManager instance] exitRoom]; [[RtcManager instance] exitRoom];
[[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil]; [[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil];
[self.roomMineView hiddenRoomMiniView]; [self.roomMineView hiddenRoomMiniView];
} }
[self.presenter logout]; [self.presenter logout];
} }
@@ -557,57 +588,57 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
if (![ClientConfig shareConfig].canOpen || [AccountInfoStorage instance].getTicket.length == 0) { if (![ClientConfig shareConfig].canOpen || [AccountInfoStorage instance].getTicket.length == 0) {
return; return;
} }
for (NIMMessage * message in messages) { for (NIMMessage * message in messages) {
if (message.session.sessionType == NIMSessionTypeP2P) { if (message.session.sessionType == NIMSessionTypeP2P) {
if(message.messageType == NIMMessageTypeCustom) { if(message.messageType == NIMMessageTypeCustom) {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel * attachment = (AttachmentModel *)obj.attachment; AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_FindNew && attachment.second == Custom_Message_Find_New_Greet_New_User) { if (attachment.first == CustomMessageType_FindNew && attachment.second == Custom_Message_Find_New_Greet_New_User) {
FindNewGreetMessageModel * greetInfo = [FindNewGreetMessageModel modelWithDictionary:attachment.data]; FindNewGreetMessageModel * greetInfo = [FindNewGreetMessageModel modelWithDictionary:attachment.data];
if (greetInfo.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) { if (greetInfo.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) {
[TTPopup dismiss]; [TTPopup dismiss];
XPSessionFindNewAlertView * alertView = [[XPSessionFindNewAlertView alloc] init]; XPSessionFindNewAlertView * alertView = [[XPSessionFindNewAlertView alloc] init];
alertView.userInfo = greetInfo; alertView.userInfo = greetInfo;
TTPopupService *service = [[TTPopupService alloc] init]; TTPopupService *service = [[TTPopupService alloc] init];
service.contentView = alertView; service.contentView = alertView;
service.shouldDismissOnBackgroundTouch = NO; service.shouldDismissOnBackgroundTouch = NO;
service.style = TTPopupStyleAlert; service.style = TTPopupStyleAlert;
[TTPopup popupWithConfig:service]; [TTPopup popupWithConfig:service];
} }
} }
} }
} }
} }
} }
} }
- (void)onReceiveBroadcastMessage:(NIMBroadcastMessage *)broadcastMessage { - (void)onReceiveBroadcastMessage:(NIMBroadcastMessage *)broadcastMessage {
if (![ClientConfig shareConfig].canOpen || [AccountInfoStorage instance].getUid.length == 0) { if (![ClientConfig shareConfig].canOpen || [AccountInfoStorage instance].getUid.length == 0) {
return; return;
} }
if (broadcastMessage.content) { if (broadcastMessage.content) {
NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject]; NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject];
AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]]; AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]];
NSString *partitionId = [NSString stringWithFormat:@"%@",attachment.data[@"partitionId"]]; NSString *partitionId = [NSString stringWithFormat:@"%@",attachment.data[@"partitionId"]];
if(![partitionId isEqualToString:self.userInfo.partitionId]){ if(![partitionId isEqualToString:self.userInfo.partitionId]){
return; return;
} }
if (attachment.first == CustomMessageType_RedPacket) { if (attachment.first == CustomMessageType_RedPacket) {
[self receiveRedPacketDealWithData:attachment]; [self receiveRedPacketDealWithData:attachment];
} else if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广 } else if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广
[self receiveBroadcastGift:attachment]; [self receiveBroadcastGift:attachment];
}else if(attachment.first == CustomMessageType_Version_Update && attachment.second == Custom_Message_Version_Update_Value){ }else if(attachment.first == CustomMessageType_Version_Update && attachment.second == Custom_Message_Version_Update_Value){
NSString *osValue = attachment.data[@"updateOs"]; NSString *osValue = attachment.data[@"updateOs"];
if([osValue isEqualToString:@"ios"] && [AccountInfoStorage instance].getUid.length > 0){ if([osValue isEqualToString:@"ios"] && [AccountInfoStorage instance].getUid.length > 0){
XPVersionUpdateModel *updateModel = [XPVersionUpdateModel modelWithDictionary:attachment.data]; XPVersionUpdateModel *updateModel = [XPVersionUpdateModel modelWithDictionary:attachment.data];
[self getVersionUpdate:updateModel]; [self getVersionUpdate:updateModel];
} }
}else if(attachment.first == CustomMessageType_LuckyBag && attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree){ }else if(attachment.first == CustomMessageType_LuckyBag && attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree){
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
[self.roomAnimation receiveLuckyGiftBigPrize:attachment]; [self.roomAnimation receiveLuckyGiftBigPrize:attachment];
}else if(attachment.first == CustomMessageType_Graffiti_Star_Kitchen && attachment.second == Custom_Message_Sub_Star_Kitchen_FullScreen){ }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; if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
[self.roomAnimation receiveAnchorHourRank:attachment]; [self.roomAnimation receiveAnchorHourRank:attachment];
}else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Noble_LevelUp_Suspend) {///VIP }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]; [self.roomAnimation receiveNobleLevelUp:attachment];
}else if (attachment.first == CustomMessageType_General_Floating_Screen && attachment.second == Custom_Message_Sub_General_Floating_Screen_All_Room){ }else if (attachment.first == CustomMessageType_General_Floating_Screen && attachment.second == Custom_Message_Sub_General_Floating_Screen_All_Room){
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
[self.roomAnimation receiveRoomGeneralFloatingScreen:attachment]; [self.roomAnimation receiveRoomGeneralFloatingScreen:attachment];
} }
} }
} }
/// ///
-(void)receiveRedPacketDealWithData:(AttachmentModel *)attachment{ -(void)receiveRedPacketDealWithData:(AttachmentModel *)attachment{
@@ -651,7 +682,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
// //
__block BOOL isInRoom; __block BOOL isInRoom;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) { if ([obj isKindOfClass:[XPRoomViewController class]]) {
*stop = YES; *stop = YES;
@@ -686,15 +717,15 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
* @discusssion * @discusssion
*/ */
- (void)onRecvRevokeMessageNotification:(NIMRevokeMessageNotification *)notification { - (void)onRecvRevokeMessageNotification:(NIMRevokeMessageNotification *)notification {
NIMMessage * message = notification.message; NIMMessage * message = notification.message;
if (message) { if (message) {
NIMMessage * revokeMessage = [[NIMMessage alloc] init]; NIMMessage * revokeMessage = [[NIMMessage alloc] init];
[revokeMessage setValue:message.session forKey:@"session"]; [revokeMessage setValue:message.session forKey:@"session"];
[revokeMessage setValue:@(NIMMessageTypeTip) forKey:@"messageType"]; [revokeMessage setValue:@(NIMMessageTypeTip) forKey:@"messageType"];
revokeMessage.timestamp = [PLTimeUtil getNowTimeTimestampMillisecond].longLongValue; revokeMessage.timestamp = [PLTimeUtil getNowTimeTimestampMillisecond].longLongValue;
revokeMessage.text = YMLocalizedString(@"TabbarViewController1"); revokeMessage.text = YMLocalizedString(@"TabbarViewController1");
[[NIMSDK sharedSDK].conversationManager saveMessage:revokeMessage forSession:message.session completion:nil]; [[NIMSDK sharedSDK].conversationManager saveMessage:revokeMessage forSession:message.session completion:nil];
} }
} }
- (void)configTheme { - (void)configTheme {
@@ -707,23 +738,23 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
} }
- (void)initTabs:(BOOL)logined { - (void)initTabs:(BOOL)logined {
self.viewControllers = nil; self.viewControllers = nil;
NSArray *normalImageNames = @[@"tab_gameHome_normal",@"tab_monents_normal",@"tab_message_normal", @"tab_mine_normal"]; 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 *selectImageNames = @[@"tab_gameHome_selected",@"tab_monents_select",@"tab_message_selected", @"tab_mine_selected"];
NSArray *tabLabel = @[YMLocalizedString(@"TabbarViewController2"),YMLocalizedString(@"TabbarViewController3"),YMLocalizedString(@"TabbarViewController4"), YMLocalizedString(@"TabbarViewController5")]; NSArray *tabLabel = @[YMLocalizedString(@"TabbarViewController2"),YMLocalizedString(@"TabbarViewController3"),YMLocalizedString(@"TabbarViewController4"), YMLocalizedString(@"TabbarViewController5")];
UIViewController *game; UIViewController *game;
UIViewController *msg; UIViewController *msg;
UIViewController *me; UIViewController *me;
UIViewController * home; UIViewController * home;
UIViewController * monents; UIViewController * monents;
///ipXPNewHomeViewController ///ipXPNewHomeViewController
[[NSNotificationCenter defaultCenter]postNotificationName:@"kInLoginVC" object:nil]; [[NSNotificationCenter defaultCenter]postNotificationName:@"kInLoginVC" object:nil];
if (logined) { if (logined) {
msg = [[XPSessionMainViewController alloc] init]; msg = [[XPSessionMainViewController alloc] init];
if ([ClientConfig shareConfig].canOpen) { if ([ClientConfig shareConfig].canOpen) {
home = [[XPNewHomeViewController alloc] init]; home = [[XPNewHomeViewController alloc] init];
monents = [[XPMonentsViewController alloc] init]; monents = [[XPMonentsViewController alloc] init];
me = [[XPMineViewController alloc] init]; me = [[XPMineViewController alloc] init];
@@ -736,12 +767,12 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
game = [[XPBlankViewController alloc]init]; game = [[XPBlankViewController alloc]init];
msg = [[XPSessionMainViewController alloc]init]; msg = [[XPSessionMainViewController alloc]init];
me = [[XPBlankViewController alloc]init]; me = [[XPBlankViewController alloc]init];
home = [[XPBlankViewController alloc] init]; home = [[XPBlankViewController alloc] init];
monents = [[XPBlankViewController alloc] init]; monents = [[XPBlankViewController alloc] init];
} }
[self createTabBarItem:home title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]]; [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:monents title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]];
[self createTabBarItem:msg title:tabLabel[2] image:normalImageNames[2] selectedImage:selectImageNames[2]]; [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 createTabBarItem:me title:tabLabel[3] image:normalImageNames[3] selectedImage:selectImageNames[3]];
self.viewControllers = @[home,monents,msg,me]; self.viewControllers = @[home,monents,msg,me];
self.selectedIndex = 0; self.selectedIndex = 0;
@@ -775,18 +806,18 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
#pragma mark - #pragma mark -
- (void)monentsUnReadCount { - (void)monentsUnReadCount {
[Api monentsUnReadCount:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { [Api monentsUnReadCount:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) { if (code == 200) {
MonentsUnReadModel * model = [MonentsUnReadModel modelWithDictionary:data.data]; MonentsUnReadModel * model = [MonentsUnReadModel modelWithDictionary:data.data];
NSString *badge = model.total > 0 ? @(model.total).stringValue : nil; NSString *badge = model.total > 0 ? @(model.total).stringValue : nil;
if (model.total > 99) { if (model.total > 99) {
badge = @"99+"; badge = @"99+";
} }
NSUInteger index = 1; NSUInteger index = 1;
UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil;
[item setBadgeValue:badge]; [item setBadgeValue:badge];
} }
} uid:[AccountInfoStorage instance].getUid]; } uid:[AccountInfoStorage instance].getUid];
NSArray *recentList = [[NIMSDK sharedSDK].conversationManager.allRecentSessions mutableCopy]; NSArray *recentList = [[NIMSDK sharedSDK].conversationManager.allRecentSessions mutableCopy];
__block NSInteger unreadCount = 0; __block NSInteger unreadCount = 0;
NSMutableArray<NSString *> * uids = [[NSMutableArray alloc] init]; NSMutableArray<NSString *> * uids = [[NSMutableArray alloc] init];
@@ -794,34 +825,34 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[uids addObject:obj.session.sessionId]; [uids addObject:obj.session.sessionId];
unreadCount += obj.unreadCount; unreadCount += obj.unreadCount;
}]; }];
if(unreadCount > 0){ if(unreadCount > 0){
NSUInteger index = 2; NSUInteger index = 2;
UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil;
[item setBadgeValue:[NSString stringWithFormat:@"%ld",unreadCount]]; [item setBadgeValue:[NSString stringWithFormat:@"%ld",unreadCount]];
} }
} }
#pragma mark - #pragma mark -
- (void)configRoomMiniNView:(NSDictionary *)dic { - (void)configRoomMiniNView:(NSDictionary *)dic {
UserInfoModel * userInfo = [UserInfoModel modelWithDictionary:dic[@"userInfo"]]; UserInfoModel * userInfo = [UserInfoModel modelWithDictionary:dic[@"userInfo"]];
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic[@"roomInfo"]]; RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic[@"roomInfo"]];
NSMutableDictionary * microQueue = dic[@"microQueue"]; NSMutableDictionary * microQueue = dic[@"microQueue"];
[self.roomMineView configRoomMiniView:roomInfo userInfo:userInfo micQueue:microQueue]; [self.roomMineView configRoomMiniView:roomInfo userInfo:userInfo micQueue:microQueue];
} }
#pragma mark - #pragma mark -
- (void)initQuickEnterRoom { - (void)initQuickEnterRoom {
NSString * key = [NSString stringWithFormat:@"%@_%@", kUserFirstLoginKey, [AccountInfoStorage instance].getUid]; NSString * key = [NSString stringWithFormat:@"%@_%@", kUserFirstLoginKey, [AccountInfoStorage instance].getUid];
BOOL isNotFirstLogin = [[NSUserDefaults standardUserDefaults] boolForKey:key]; BOOL isNotFirstLogin = [[NSUserDefaults standardUserDefaults] boolForKey:key];
if (!isNotFirstLogin) { if (!isNotFirstLogin) {
/// ///
// [self.presenter getNewUserGreetInfo]; // [self.presenter getNewUserGreetInfo];
} }
} }
/// linkedMe /// linkedMe
- (void)completeUserInfoFinish:(NSString *)inviteCode { - (void)completeUserInfoFinish:(NSString *)inviteCode {
self.inviteCode = inviteCode; self.inviteCode = inviteCode;
} }
#pragma mark -NIMSystemNotificationManagerDelegate #pragma mark -NIMSystemNotificationManagerDelegate
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification { - (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification {
@@ -960,98 +991,98 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
} }
- (void)handleAnchorCardSwipeFrom:(UISwipeGestureRecognizer *)recognizer{ - (void)handleAnchorCardSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
if(recognizer.direction == UISwipeGestureRecognizerDirectionUp) { if(recognizer.direction == UISwipeGestureRecognizerDirectionUp) {
[UIView animateWithDuration:0.5 animations:^{ [UIView animateWithDuration:0.5 animations:^{
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90); self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
} completion:^(BOOL finished) { } completion:^(BOOL finished) {
[self.anchorCardView removeFromSuperview]; [self.anchorCardView removeFromSuperview];
self.anchorCardView = nil; self.anchorCardView = nil;
self.needShowAnchorCard = NO; self.needShowAnchorCard = NO;
}]; }];
} }
} }
#pragma mark - #pragma mark -
- (void)receiveBroadcastGift:(AttachmentModel *)attachment { - (void)receiveBroadcastGift:(AttachmentModel *)attachment {
GiftReceiveInfoModel *giftNotifyInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data]; GiftReceiveInfoModel *giftNotifyInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
if (!giftNotifyInfo.ceremonyGift && giftNotifyInfo.isHomeShow == YES) { if (!giftNotifyInfo.ceremonyGift && giftNotifyInfo.isHomeShow == YES) {
if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return;
[self.roomAnimation receiveGift:giftNotifyInfo]; [self.roomAnimation receiveGift:giftNotifyInfo];
return; return;
} }
if(giftNotifyInfo.isHomeShow == NO)return; if(giftNotifyInfo.isHomeShow == NO)return;
if (self.giftBroadcastQueue.count == 0) { if (self.giftBroadcastQueue.count == 0) {
[self createGiftBroadcastViewAnimation:giftNotifyInfo]; [self createGiftBroadcastViewAnimation:giftNotifyInfo];
} }
[self.giftBroadcastQueue addObject:giftNotifyInfo]; [self.giftBroadcastQueue addObject:giftNotifyInfo];
} }
- (void)createGiftBroadcastViewAnimation:(GiftReceiveInfoModel *)giftModel { - (void)createGiftBroadcastViewAnimation:(GiftReceiveInfoModel *)giftModel {
XPRoomYearActivityView * view = [[XPRoomYearActivityView alloc] init]; XPRoomYearActivityView * view = [[XPRoomYearActivityView alloc] init];
view.delegate = self; view.delegate = self;
view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, 150); view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, 150);
view.model = giftModel; view.model = giftModel;
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:view]; [[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:view];
[self beginGiftBraodcastViewAnimation:view notifyStaySecond:giftModel.notifyStaySecond]; [self beginGiftBraodcastViewAnimation:view notifyStaySecond:giftModel.notifyStaySecond];
} }
- (void)beginGiftBraodcastViewAnimation:(XPRoomYearActivityView *)view notifyStaySecond:(int)notifyStaySecond{ - (void)beginGiftBraodcastViewAnimation:(XPRoomYearActivityView *)view notifyStaySecond:(int)notifyStaySecond{
CGFloat startTime = notifyStaySecond > 0 ? notifyStaySecond : 3.0; CGFloat startTime = notifyStaySecond > 0 ? notifyStaySecond : 3.0;
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12; springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f; springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:view.center]; springAnimation.fromValue = [NSValue valueWithCGPoint:view.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0 + view.frame.size.width / 2, view.center.y)]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0 + view.frame.size.width / 2, view.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) { if (finished) {
[self removeGiftBroadcastOutAnimation:view stayTime:startTime]; [self removeGiftBroadcastOutAnimation:view stayTime:startTime];
} }
}]; }];
[view pop_addAnimation:springAnimation forKey:@"spingOutAnimation"]; [view pop_addAnimation:springAnimation forKey:@"spingOutAnimation"];
} }
- (void)removeGiftBroadcastOutAnimation:(XPRoomYearActivityView *)view stayTime:(CGFloat)stayTime{ - (void)removeGiftBroadcastOutAnimation:(XPRoomYearActivityView *)view stayTime:(CGFloat)stayTime{
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:view.center]; moveAnimation.fromValue = [NSValue valueWithCGPoint:view.center];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, view.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, view.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + stayTime; moveAnimation.beginTime = CACurrentMediaTime() + stayTime;
moveAnimation.duration = 0.5; moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1; moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES; moveAnimation.removedOnCompletion = YES;
@kWeakify(self); @kWeakify(self);
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
@kStrongify(self); @kStrongify(self);
if (finished) { if (finished) {
[view removeFromSuperview]; [view removeFromSuperview];
if (self.giftBroadcastQueue.count > 0) { if (self.giftBroadcastQueue.count > 0) {
[self.giftBroadcastQueue removeObjectAtIndex:0]; [self.giftBroadcastQueue removeObjectAtIndex:0];
} }
if (self.giftBroadcastQueue.count > 0) { if (self.giftBroadcastQueue.count > 0) {
[self createGiftBroadcastViewAnimation:self.giftBroadcastQueue.firstObject]; [self createGiftBroadcastViewAnimation:self.giftBroadcastQueue.firstObject];
} }
} }
}]; }];
[view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; [view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
} }
#pragma mark - XPRoomGiftBroadcastViewDelegate #pragma mark - XPRoomGiftBroadcastViewDelegate
- (void)xPRoomYearActivityViewEnterRoom:(NSString *)roomUid{ - (void)xPRoomYearActivityViewEnterRoom:(NSString *)roomUid{
if (roomUid.length > 0) { if (roomUid.length > 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 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]; [XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
}); });
} }
} }
#pragma mark - Getters And Setters #pragma mark - Getters And Setters
- (XPMiniRoomView *)roomMineView { - (XPMiniRoomView *)roomMineView {
if (!_roomMineView) { if (!_roomMineView) {
_roomMineView = [[XPMiniRoomView alloc] init]; _roomMineView = [[XPMiniRoomView alloc] init];
_roomMineView.controller = self; _roomMineView.controller = self;
_roomMineView.hidden = YES; _roomMineView.hidden = YES;
} }
return _roomMineView; return _roomMineView;
} }
- (XPAnchorCardView *)anchorCardView { - (XPAnchorCardView *)anchorCardView {
@@ -1071,10 +1102,10 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
} }
- (NSMutableArray<GiftReceiveInfoModel *> *)giftBroadcastQueue { - (NSMutableArray<GiftReceiveInfoModel *> *)giftBroadcastQueue {
if (!_giftBroadcastQueue) { if (!_giftBroadcastQueue) {
_giftBroadcastQueue = [NSMutableArray array]; _giftBroadcastQueue = [NSMutableArray array];
} }
return _giftBroadcastQueue; return _giftBroadcastQueue;
} }
- (PIFullScreenBannerAnimation *)roomAnimation{ - (PIFullScreenBannerAnimation *)roomAnimation{
if(!_roomAnimation){ if(!_roomAnimation){

View File

@@ -260,7 +260,8 @@ static UploadFile* manager;
} }
+(void)downloadAudioWithFileName:(NSString *)fileName musicUrl:(NSString *)musicUrl mainFileName:(NSString *)mainFileName completion:(void (^) (BOOL isSuccess, NSString *editAudioPath))completion { +(void)downloadAudioWithFileName:(NSString *)fileName musicUrl:(NSString *)musicUrl mainFileName:(NSString *)mainFileName completion:(void (^) (BOOL isSuccess, NSString *editAudioPath))completion {
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; 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) { NSURLSessionDownloadTask *download = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:mainFileName] stringByAppendingPathComponent:fileName]; NSString *filePath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:mainFileName] stringByAppendingPathComponent:fileName];

View File

@@ -164,8 +164,8 @@
"PKIDLoginViewController2" = "Please contact customer service"; "PKIDLoginViewController2" = "Please contact customer service";
"PKIDLoginViewController3" = "LINEpekoyuyin"; "PKIDLoginViewController3" = "LINEpekoyuyin";
"PKIDLoginViewController4" = "I understand"; "PKIDLoginViewController4" = "I understand";
"MessageLevelUpgradeModel0" = "Congratulations! Your charm level has reached Lv%@"; "MessageLevelUpgradeModel0" = "Congratulations! Your charm level has reached %@";
"MessageLevelUpgradeModel1" = "Congratulations! Your level has reached Lv%@"; "MessageLevelUpgradeModel1" = "Congratulations! Your level has reached %@";
"MessageTextModel0" = "Unknown message type"; "MessageTextModel0" = "Unknown message type";

View File

@@ -1962,8 +1962,8 @@
"PKIDLoginViewController2" = "请联繫客服处理"; "PKIDLoginViewController2" = "请联繫客服处理";
"PKIDLoginViewController3" = "LINEpekoyuyin"; "PKIDLoginViewController3" = "LINEpekoyuyin";
"PKIDLoginViewController4" = "我知道了"; "PKIDLoginViewController4" = "我知道了";
"MessageLevelUpgradeModel0" = "恭喜!您的魅力等级已到达Lv%@"; "MessageLevelUpgradeModel0" = "恭喜!您的魅力等级已到达%@";
"MessageLevelUpgradeModel1" = "恭喜!您的等级已到达Lv%@"; "MessageLevelUpgradeModel1" = "恭喜!您的等级已到达%@";
"MessageTextModel0" = "未知消息类型"; "MessageTextModel0" = "未知消息类型";

View File

@@ -1957,8 +1957,8 @@
"PKIDLoginViewController2" = "請聯繫客服處理"; "PKIDLoginViewController2" = "請聯繫客服處理";
"PKIDLoginViewController3" = "LINEpekoyuyin"; "PKIDLoginViewController3" = "LINEpekoyuyin";
"PKIDLoginViewController4" = "我知道了"; "PKIDLoginViewController4" = "我知道了";
"MessageLevelUpgradeModel0" = "恭喜!您的魅力等級已到達Lv%@"; "MessageLevelUpgradeModel0" = "恭喜!您的魅力等級已到達%@";
"MessageLevelUpgradeModel1" = "恭喜!您的等級已到達Lv%@"; "MessageLevelUpgradeModel1" = "恭喜!您的等級已到達%@";
"MessageTextModel0" = "未知消息類型"; "MessageTextModel0" = "未知消息類型";