1.缓存优化,bug修复

This commit is contained in:
liyuhua
2024-05-17 16:57:28 +08:00
parent 82a476fd46
commit 2c3c6ad17d
15 changed files with 141 additions and 84 deletions

View File

@@ -67,7 +67,7 @@
[[self getView]onGetClanDetailInfofail];
return;
}
[Api getClanDetailInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[Api getNewClanDetailInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
ClanDetailInfoModel * clanDetailInfo = [ClanDetailInfoModel modelWithDictionary:data.data];
[[self getView] onGetClanDetailInfoSuccess:clanDetailInfo];
}fail:^(NSInteger code, NSString * _Nullable msg) {

View File

@@ -14,7 +14,10 @@ NS_ASSUME_NONNULL_BEGIN
@interface Api (Guild)
/// 获取家族详情
/// @param completion 完成
/// @param uid 族长的uid
+ (void)getNewClanDetailInfo:(HttpRequestHelperCompletion)completion uid:(NSString *)uid;
/// 获取家族详情
/// @param completion 完成
/// @param uid 族长的uid

View File

@@ -15,7 +15,12 @@
+ (void)getClanDetailInfo:(HttpRequestHelperCompletion)completion uid:(NSString *)uid {
[self makeRequest:@"clan/getUserHallAndClan" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, uid, nil];
}
///
/// @param completion
/// @param uid uid
+ (void)getNewClanDetailInfo:(HttpRequestHelperCompletion)completion uid:(NSString *)uid {
[self makeRequest:@"user/getUserClanInfo" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, uid, nil];
}
///
/// @param completion
/// @param clanId id

View File

@@ -6,15 +6,12 @@
//
#import "MvpViewController.h"
#import "ClanDetailInfoModel.h"
#import "UserInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPIncomeRecordVC : MvpViewController
///家族信息
@property (nonatomic,strong) ClanDetailInfoModel *clanInfo;
///个人信息
@property (nonatomic,strong) UserInfoModel *userInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -454,8 +454,7 @@ UIKIT_EXTERN NSString *kRequestRicket;
-(void)pushEarningsRecordVC{
XPIncomeRecordVC *incomeRecordVC = [XPIncomeRecordVC new];
incomeRecordVC.clanInfo = self.clanInfo;
incomeRecordVC.userInfo = self.userInfo;
[self.navigationController pushViewController:incomeRecordVC animated:YES];
}

View File

@@ -2099,7 +2099,7 @@
};
[self.parser parseWithURL:[NSURL URLWithString:vggUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
[self.parser parseWithURL:[NSURL URLWithString:encodingUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
if (videoItem != nil) {
self.giftEffectView.hidden = NO;
@@ -2181,7 +2181,7 @@
[self.vapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self];
return;
}
[self.vapParser parseWithURL:vapUrl completionBlock:^(NSString * _Nullable videoUrl) {
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
if (videoUrl.length) {
self.vapGiftEffectView.hidden = NO;
@@ -2248,7 +2248,7 @@
};
[self.parser parseWithURL:vggUrl completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
[self.parser parseWithURL:[NSURL URLWithString:encodingUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
if (videoItem != nil) {
self.luckyGiftEffectView.hidden = NO;
if (self.luckyGiftEffectView.superview == nil) {
@@ -2303,7 +2303,7 @@
[self.luckyVapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self];
return;
}
[self.vapParser parseWithURL:vapUrl completionBlock:^(NSString * _Nullable videoUrl) {
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
if (videoUrl.length) {
self.luckyVapGiftEffectView.hidden = NO;
if (self.luckyVapGiftEffectView.superview == nil) {

View File

@@ -19,9 +19,9 @@ typedef NS_ENUM(NSInteger, RoomMoreMenuType) {
// ///公屏开启
// RoomMoreMenuType_Message_Screen_Open = 4,
// ///我的礼物特效关闭
// RoomMoreMenuType_Gift_Effect_Close = 5,
// ///我的礼物特效开启
// RoomMoreMenuType_Gift_Effect_Open = 6,
RoomMoreMenuType_Gift_Effect_Close = 5,
///我的礼物特效开启
RoomMoreMenuType_Gift_Effect_Open = 6,
///房间设置
RoomMoreMenuType_Room_Setting = 7,
///邀请粉丝

View File

@@ -38,11 +38,11 @@
// giftValue.type = roomInfo.showGiftValue ? RoomMoreMenuType_Gift_Value_Close : RoomMoreMenuType_Gift_Value_Open;
// giftValue.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor];
// XPRoomMoreItemModel * giftEffect = [[XPRoomMoreItemModel alloc] init];
// giftEffect.title = roomInfo.hasAnimationEffect ? YMLocalizedString(@"XPMoreMenuPresenter28") : YMLocalizedString(@"XPMoreMenuPresenter5");
// giftEffect.imageName = @"room_more_menu_gift_effect";
// giftEffect.type = roomInfo.hasAnimationEffect ? RoomMoreMenuType_Gift_Effect_Close : RoomMoreMenuType_Gift_Effect_Open;
// giftEffect.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor];
XPRoomMoreItemModel * giftEffect = [[XPRoomMoreItemModel alloc] init];
giftEffect.title = roomInfo.hasAnimationEffect ? YMLocalizedString(@"XPMoreMenuPresenter28") : YMLocalizedString(@"XPMoreMenuPresenter5");
giftEffect.imageName = @"room_more_menu_gift_effect";
giftEffect.type = roomInfo.hasAnimationEffect ? RoomMoreMenuType_Gift_Effect_Close : RoomMoreMenuType_Gift_Effect_Open;
giftEffect.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor];
XPRoomMoreItemModel * wishGift = [[XPRoomMoreItemModel alloc] init];
wishGift.title = YMLocalizedString(@"XPMoreMenuPresenter6");
@@ -179,15 +179,17 @@
// if (isCreator && roomInfo.type != RoomType_Anchor && roomInfo.isPermitRoom != PermitRoomType_Licnese && roomInfo.isPermitRoom != PermitRoomType_YoungerStar) {
// [array addObject:releaseRadio];
// }
[array addObject:giftEffect];
[array addObject:roomSetting];
[array addObject:clearScreen];
} else {
[array addObject:trumpet];
[array addObject:giftEffect];
}
}else{
[array addObject:giftEffect];
}

View File

@@ -277,24 +277,24 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
// [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"closeScreen"}];
// [self.presenter updateRoomMessageScreenState:YES roomId:roomId];
// break;
// case RoomMoreMenuType_Gift_Effect_Open:
// {
// [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"openGiftEffect"}];
// [self showSuccessToast:YMLocalizedString(@"XPRoomMoreMenuViewController4")];
// NSDictionary * dic = @{@"hasAnimationEffect": @(1)};
// [[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic];
// [self dismissViewControllerAnimated:YES completion:nil];
// }
// break;
// case RoomMoreMenuType_Gift_Effect_Close:
// {
// [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"closeGiftEffect"}];
// [self showSuccessToast:YMLocalizedString(@"XPRoomMoreMenuViewController5")];
// NSDictionary * dic = @{@"hasAnimationEffect": @(0)};
// [[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic];
// [self dismissViewControllerAnimated:YES completion:nil];
// }
// break;
case RoomMoreMenuType_Gift_Effect_Open:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"openGiftEffect"}];
[self showSuccessToast:YMLocalizedString(@"XPRoomMoreMenuViewController4")];
NSDictionary * dic = @{@"hasAnimationEffect": @(1)};
[[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic];
[self dismissViewControllerAnimated:YES completion:nil];
}
break;
case RoomMoreMenuType_Gift_Effect_Close:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"closeGiftEffect"}];
[self showSuccessToast:YMLocalizedString(@"XPRoomMoreMenuViewController5")];
NSDictionary * dic = @{@"hasAnimationEffect": @(0)};
[[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic];
[self dismissViewControllerAnimated:YES completion:nil];
}
break;
case RoomMoreMenuType_Invite_Fans:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"inviteFans"}];

View File

@@ -488,7 +488,7 @@
[view playHWDMP4:fullPath repeatCount:1 delegate:self];
}else{
[self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) {
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
if (videoUrl.length) {
[view setMute:YES];
[view playHWDMP4:videoUrl repeatCount:1 delegate:self];

View File

@@ -293,7 +293,7 @@
[self.trialsView playHWDMP4:fullPath repeatCount:1 delegate:self];
}else{
[self.vapParser parseWithURL:filePath completionBlock:^(NSString * _Nullable videoUrl) {
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
if (videoUrl.length) {
[self.trialsView setMute:YES];
[self.trialsView playHWDMP4:videoUrl repeatCount:1 delegate:self];

View File

@@ -124,7 +124,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
@property(nonatomic,assign) BOOL isReloadTicket;
///
@property(nonatomic,strong) PIFullScreenBannerAnimation *roomAnimation;
///
@property(nonatomic,assign) int downloadGiftCount;
@end
@@ -349,17 +350,16 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
case AFNetworkReachabilityStatusReachableViaWiFi:
{
if(self.isFirstReachability == NO){
[self dealWithDefaultSvga];
[self dealWithGiftList];
[Api requestCacheGiftDynamicEffectList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
self.isFirstReachability = YES;
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];
}
NSMutableArray *giftList = [[NSMutableArray alloc]initWithArray:data.data ?: @[]];
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"];
[giftList addObjectsFromArray:elfList];
NSSet *setList = [[NSSet alloc]initWithArray:giftList];///
[self cacheGiftDynamicEffectList:setList];
}
}];
}
@@ -374,32 +374,27 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
}
-(void)dealWithDefaultSvga{
///
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) {
NSString *encodingUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet];
[self cacheGiftDynamicEffectList:encodingUrl];
}
}
///
-(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{
///
-(void)cacheGiftDynamicEffectList:(NSSet *)list{
[UploadFile downloadGiftDynamicEffectWithList:list completion:^(BOOL isSuccess, NSMutableArray * _Nonnull failList) {
if(isSuccess == NO){
if(self.downloadGiftCount > 3 || failList.count == 0){
return;
}
[self downloadGiftDynamicEffectWithList:failList];
}
}];
}
-(void)downloadGiftDynamicEffectWithList:( NSMutableArray * )requestList{
NSSet *setList = [[NSSet alloc]initWithArray:requestList];
[UploadFile downloadGiftDynamicEffectWithList:setList completion:^(BOOL isSuccess, NSMutableArray * _Nonnull failList) {
if(isSuccess == NO){
if(self.downloadGiftCount > 3 || failList.count == 0){
return;
}
self.downloadGiftCount++;
[self downloadGiftDynamicEffectWithList:failList];
}
}];
}

View File

@@ -30,6 +30,7 @@
#import "XPIAPRechargeViewController.h"
#import "SessionViewController.h"
#import "XPMonentTopicContainerViewController.h"
#import "XPIncomeRecordVC.h"
#import "PIWebViewSavePhotoView.h"
@@ -111,6 +112,8 @@ NSString * const kJSOpenRoomForGiftId = @"openRoomForGiftId";
NSString * const kJSOpenChatPage = @"geToChatPage";
NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
NSString * const kJSSavePictureShare = @"savePictureShare";
NSString * const kJSGoToExchangeGold = @"goToExchangeGold";
@implementation XPWebViewController
@@ -281,7 +284,9 @@ NSString * const kJSSavePictureShare = @"savePictureShare";
if (![scheme isEqualToString:@"https"] && ![scheme isEqualToString:@"http"]) {
BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:request.URL];
if (canOpen) {
[[UIApplication sharedApplication] openURL:request.URL];
[[UIApplication sharedApplication] openURL:request.URL options:@{} completionHandler:^(BOOL success) {
}];
}
decisionHandler(WKNavigationActionPolicyCancel);
return;
@@ -347,20 +352,17 @@ NSString * const kJSSavePictureShare = @"savePictureShare";
} else if ([message.name isEqualToString:kJSOpenPurse]) {
}else if([message.name isEqualToString:kJSChargePayPage]){
NSString *money = [NSString stringWithFormat:@"%@",message.body] ;
// NSString *money = [NSString stringWithFormat:@"%@",message.body] ;
}else if([message.name isEqualToString:kJSChargePayClickPage]){
if(message.body != nil && self.model.diamonds != nil){
NSString *type = [NSString stringWithFormat:@"%@",message.body];
// NSString *type = [NSString stringWithFormat:@"%@",message.body];
}
}else if ([message.name isEqualToString:kJSOpenChargePage]) {
if(self.delegate && [self.delegate respondsToSelector:@selector(payHandler)]){
[self.delegate payHandler];
return;
}
[TTPopup dismiss];
if(self.isPush){
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
@@ -499,6 +501,9 @@ NSString * const kJSSavePictureShare = @"savePictureShare";
self.savePhotoDic = bodyDic;
[self showShareSavePhote];
}
}else if([message.name isEqualToString:kJSGoToExchangeGold]){
XPIncomeRecordVC *incomeRecordVC = [XPIncomeRecordVC new];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:incomeRecordVC animated:YES];
}
}
}];
@@ -849,6 +854,9 @@ NSString * const kJSSavePictureShare = @"savePictureShare";
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenAppConcernedChat];
///
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSSavePictureShare];
///
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGoToExchangeGold];
}
return _pi_userContentController;

View File

@@ -38,6 +38,8 @@ NS_ASSUME_NONNULL_BEGIN
///下载资料
-(void)downloadAnimationFileName:(NSString *)fileName localPath:(NSString *)localPath completion:(void (^) (BOOL isSuccess, NSString *editAudioPath))completion;
///下载礼物特效
+(void)downloadGiftDynamicEffectWithList:(NSSet *)list completion:(void (^) (BOOL isSuccess, NSMutableArray *editAudioPath))completion;
@end
NS_ASSUME_NONNULL_END

View File

@@ -275,4 +275,50 @@ static UploadFile* manager;
}];
[download resume];
}
+(void)downloadGiftDynamicEffectWithList:(NSSet *)list completion:(void (^) (BOOL isSuccess, NSMutableArray *editAudioPath))completion{
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.operationQueue.maxConcurrentOperationCount = 20; //
dispatch_group_t requestGroup = dispatch_group_create();
NSMutableArray *failList = [NSMutableArray array];
for (NSString *giftUrl in list) {
NSString *encodingUrl = [giftUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "].invertedSet];
NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) safeObjectAtIndex1:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
continue;
}
NSFileManager *fileMgr = [[NSFileManager alloc] init];
[fileMgr createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
dispatch_group_enter(requestGroup);
NSURL *url = [NSURL URLWithString:[encodingUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
NSURLRequest *request = [NSURLRequest requestWithURL :url];
NSURLSessionDownloadTask *download = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
return [NSURL fileURLWithPath:fullPath];
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
dispatch_group_leave(requestGroup);
if (!error) {
NSLog(@"下载完成");
} else {
NSLog(@"下载失败");
[failList addObject:encodingUrl];
}
}];
[download resume];
}
dispatch_group_notify(requestGroup, dispatch_get_main_queue(), ^{
if(failList.count > 0){
completion(NO,failList);
NSLog(@"下载有失败");
}else{
NSLog(@"下载全部完成");
completion(NO,nil);
}
});
}
@end