礼物动效缓存
This commit is contained in:
@@ -96,7 +96,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
|
||||
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate,XPLoginAuthCodeVCDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate, XPRoomYearActivityViewDelegate>
|
||||
{
|
||||
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<NSString *> * 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<GiftReceiveInfoModel *> *)giftBroadcastQueue {
|
||||
if (!_giftBroadcastQueue) {
|
||||
_giftBroadcastQueue = [NSMutableArray array];
|
||||
}
|
||||
return _giftBroadcastQueue;
|
||||
if (!_giftBroadcastQueue) {
|
||||
_giftBroadcastQueue = [NSMutableArray array];
|
||||
}
|
||||
return _giftBroadcastQueue;
|
||||
}
|
||||
- (PIFullScreenBannerAnimation *)roomAnimation{
|
||||
if(!_roomAnimation){
|
||||
|
Reference in New Issue
Block a user