diff --git a/YuMi.xcodeproj/project.pbxproj b/YuMi.xcodeproj/project.pbxproj index 8457b81f..b7089b7e 100644 --- a/YuMi.xcodeproj/project.pbxproj +++ b/YuMi.xcodeproj/project.pbxproj @@ -485,6 +485,7 @@ 23FF42762AA6E1480055733C /* XPHomeRecommendOtherRoomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF42752AA6E1480055733C /* XPHomeRecommendOtherRoomView.m */; }; 23FF42792AA6E19C0055733C /* HomeMenuSourceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF42782AA6E19C0055733C /* HomeMenuSourceModel.m */; }; 23FF428E2AAB2D3A0055733C /* XPCandyTreeBuyView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF428D2AAB2D3A0055733C /* XPCandyTreeBuyView.m */; }; + 4C1064882E0014CF007E1586 /* NSMutableArray+Safe.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1064872E0014CF007E1586 /* NSMutableArray+Safe.m */; }; 4C1119722DD7218300C18416 /* MyEventsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1119712DD7218300C18416 /* MyEventsViewController.m */; }; 4C1392932D6D963700A6DFB5 /* SubRechargersViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1392922D6D963600A6DFB5 /* SubRechargersViewController.m */; }; 4C1392962D6DA22B00A6DFB5 /* RechargerTransferHistoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C1392952D6DA22B00A6DFB5 /* RechargerTransferHistoryViewController.m */; }; @@ -2629,6 +2630,8 @@ 23FF42782AA6E19C0055733C /* HomeMenuSourceModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeMenuSourceModel.m; sourceTree = ""; }; 23FF428C2AAB2D3A0055733C /* XPCandyTreeBuyView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeBuyView.h; sourceTree = ""; }; 23FF428D2AAB2D3A0055733C /* XPCandyTreeBuyView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeBuyView.m; sourceTree = ""; }; + 4C1064862E0014CF007E1586 /* NSMutableArray+Safe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+Safe.h"; sourceTree = ""; }; + 4C1064872E0014CF007E1586 /* NSMutableArray+Safe.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSMutableArray+Safe.m"; sourceTree = ""; }; 4C1119702DD7218300C18416 /* MyEventsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyEventsViewController.h; sourceTree = ""; }; 4C1119712DD7218300C18416 /* MyEventsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyEventsViewController.m; sourceTree = ""; }; 4C1392912D6D963600A6DFB5 /* SubRechargersViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SubRechargersViewController.h; sourceTree = ""; }; @@ -11690,6 +11693,8 @@ E8F61356291E269700E12650 /* Safe */ = { isa = PBXGroup; children = ( + 4C1064862E0014CF007E1586 /* NSMutableArray+Safe.h */, + 4C1064872E0014CF007E1586 /* NSMutableArray+Safe.m */, E8F6135A291E26BD00E12650 /* NSMutableDictionary+Saft.h */, E8F6135B291E26BD00E12650 /* NSMutableDictionary+Saft.m */, E8F6135D291E274E00E12650 /* NSArray+Safe.h */, @@ -13109,6 +13114,7 @@ E801275527E3326000BAC3F2 /* XPRoomPKUserView.m in Sources */, 2305EF132AD8036B00AD403C /* PIRoomMessagePhotoAlbumView.m in Sources */, E8FE3C2C2994D0E80006C6C7 /* XPSwitch.m in Sources */, + 4C1064882E0014CF007E1586 /* NSMutableArray+Safe.m in Sources */, E8D4824D278D2CE4003C1D08 /* XPAcrossRoomPKInviteResultView.m in Sources */, E81E09CC290F732600A1F410 /* XPAdImageTool.m in Sources */, 9BD8D4E628911F7700AE03FF /* XPMineCollectRoomListPresenter.m in Sources */, diff --git a/YuMi/Appdelegate/AppDelegate+ThirdConfig.m b/YuMi/Appdelegate/AppDelegate+ThirdConfig.m index c09c0a73..3607db6a 100644 --- a/YuMi/Appdelegate/AppDelegate+ThirdConfig.m +++ b/YuMi/Appdelegate/AppDelegate+ThirdConfig.m @@ -146,12 +146,18 @@ UIKIT_EXTERN NSString * adImageName; NSArray * emojiArray = dic[@"data"]; NSMutableArray * array = [NSMutableArray array]; for (int i = 0; i < emojiArray.count; i++) { - NSDictionary * dic = [emojiArray objectAtIndex:i]; + UIImage * image = [UIImage imageNamed:dic[@"file"]]; QEmotion * info = [[QEmotion alloc] init]; - info.identifier = dic[@"id"]; + + NSDictionary * dic = [emojiArray xpSafeObjectAtIndex:i]; + if (dic) { + info.displayName = dic[@"tag"]; + info.identifier = dic[@"id"]; + } + info.image = image; - info.displayName = dic[@"tag"]; + [array addObject:info]; } //在这里强烈建议先预加载一下表情 diff --git a/YuMi/CustomUI/Adbvertise/AdvertiseModel.h b/YuMi/CustomUI/Adbvertise/AdvertiseModel.h index b54aad17..7d89274f 100644 --- a/YuMi/CustomUI/Adbvertise/AdvertiseModel.h +++ b/YuMi/CustomUI/Adbvertise/AdvertiseModel.h @@ -18,7 +18,7 @@ typedef NS_ENUM(NSInteger, SplashInfoSkipType) { SplashInfoSkipTypeWeb_Custom = 6, }; -@interface AdvertiseFillModel : PIBaseModel +@interface AdvertiseFillModel : PIBaseModel// @property(nonatomic, copy) NSString *loverNick; @property(nonatomic, copy) NSString *loverErbanNo; @@ -32,7 +32,7 @@ typedef NS_ENUM(NSInteger, SplashInfoSkipType) { @end -@interface AdvertiseModel : PIBaseModel +@interface AdvertiseModel : PIBaseModel// @property (nonatomic, strong) NSString *link; @property (nonatomic, assign) SplashInfoSkipType type;// 1跳app页面,2跳聊天室,3跳h5页面, @property (nonatomic, copy) NSString *pict; diff --git a/YuMi/CustomUI/Adbvertise/AdvertiseModel.m b/YuMi/CustomUI/Adbvertise/AdvertiseModel.m index 48f80724..8cfd83ed 100644 --- a/YuMi/CustomUI/Adbvertise/AdvertiseModel.m +++ b/YuMi/CustomUI/Adbvertise/AdvertiseModel.m @@ -9,7 +9,6 @@ @implementation AdvertiseFillModel - @end @implementation AdvertiseModel @@ -20,4 +19,5 @@ }; } + @end diff --git a/YuMi/CustomUI/Adbvertise/XPAdImageTool.m b/YuMi/CustomUI/Adbvertise/XPAdImageTool.m index d541946a..f4ed0b26 100644 --- a/YuMi/CustomUI/Adbvertise/XPAdImageTool.m +++ b/YuMi/CustomUI/Adbvertise/XPAdImageTool.m @@ -42,7 +42,7 @@ static XPAdImageTool* tool; - (AdvertiseModel *)getAdInfoFromCacheInMainWith:(NSString *)link { if (link.length > 0) { if ([self.yyCache containsObjectForKey:link]) { - return [self.yyCache objectForKey:link]; + return (AdvertiseModel *)[self.yyCache objectForKey:link]; }else { return nil; } @@ -58,7 +58,7 @@ static XPAdImageTool* tool; self.infoModel = adInfo; NSArray *stringArr = [adInfo.pict componentsSeparatedByString:@"/"]; NSString *key = stringArr.lastObject; - [self.yyCache setObject:adInfo forKey:key withBlock:^{ + [self.yyCache setObject:(id )adInfo forKey:key withBlock:^{ }]; @@ -148,7 +148,7 @@ static XPAdImageTool* tool; - (NSString *)getFilePathWithImageName:(NSString *)imageName { if (imageName) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES); - NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:imageName]; + NSString *filePath = [[paths xpSafeObjectAtIndex:0] stringByAppendingPathComponent:imageName]; return filePath; } diff --git a/YuMi/CustomUI/InputView/InputView/QInputBarView.m b/YuMi/CustomUI/InputView/InputView/QInputBarView.m index ee53adee..6615b56a 100755 --- a/YuMi/CustomUI/InputView/InputView/QInputBarView.m +++ b/YuMi/CustomUI/InputView/InputView/QInputBarView.m @@ -202,7 +202,10 @@ const int UIInputTextViewMaxHeight = 147; [self addSubview:textView]; textView.frame = CGRectMake(textViewFrameX + textViewHorizontalMargin, (UIInputBarViewMinHeight - UIInputTextViewMinHeight)/2, textViewWidth, UIInputTextViewMinHeight); - self.inputTextView = textView; + if ([textView isKindOfClass:[SZTextView class]]) { + self.inputTextView = (SZTextView *)textView; + } + for (id view in textView.subviews) { if ([view isKindOfClass:[UITextView class]]){ UITextView *textView = view; diff --git a/YuMi/CustomUI/MSRTL/UITextView+MSRTL.m b/YuMi/CustomUI/MSRTL/UITextView+MSRTL.m index 7f42f2f5..520b77a8 100644 --- a/YuMi/CustomUI/MSRTL/UITextView+MSRTL.m +++ b/YuMi/CustomUI/MSRTL/UITextView+MSRTL.m @@ -58,7 +58,7 @@ } - (void)msrtl_setPlaceholder:(NSString *)placeholder { - NSAttributedString * attribute = [[NSAttributedString alloc] initWithString:placeholder]; +// NSAttributedString * attribute = [[NSAttributedString alloc] initWithString:placeholder]; // self.attributedPlaceholder = attribute; } diff --git a/YuMi/CustomUI/ShareView/XPShareView.m b/YuMi/CustomUI/ShareView/XPShareView.m index 8bf10318..5a5a51e0 100644 --- a/YuMi/CustomUI/ShareView/XPShareView.m +++ b/YuMi/CustomUI/ShareView/XPShareView.m @@ -169,7 +169,7 @@ self.shareInfo.shareType = item.type; - SSDKPlatformType platformType; + SSDKPlatformType platformType = SSDKPlatformTypeCopy; if (item.type == XPShareItemTagLine) { title = YMLocalizedString(@"XPShareView1"); diff --git a/YuMi/Modules/YMLogin/View/LoginViewController.m b/YuMi/Modules/YMLogin/View/LoginViewController.m index 4553a091..db29e532 100644 --- a/YuMi/Modules/YMLogin/View/LoginViewController.m +++ b/YuMi/Modules/YMLogin/View/LoginViewController.m @@ -472,7 +472,7 @@ typedef NS_ENUM(NSUInteger, LoginType) { - (NSArray *)shiftedColorsFromColors:(NSArray *)colors { NSMutableArray *mutableColors = [colors mutableCopy]; id firstColor = [mutableColors firstObject]; - [mutableColors removeObjectAtIndex:0]; + [mutableColors xpSafeRemoveObjectAtIndex:0]; [mutableColors addObject:firstColor]; return [mutableColors copy]; } diff --git a/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageMonentsAutoModel.m b/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageMonentsAutoModel.m index 916f1f90..2eb885c6 100644 --- a/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageMonentsAutoModel.m +++ b/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageMonentsAutoModel.m @@ -16,7 +16,7 @@ if (self = [super initWithMessage:message]) { self.messageType = SessionMessageType_Custom; NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; - AttachmentModel * attach = obj.attachment; + AttachmentModel * attach = (AttachmentModel *)obj.attachment; NSDictionary * dic = attach.data; GuildMessageModel *model = [GuildMessageModel modelWithDictionary:dic]; GuildMessageLayoutModel * layout = model.layout; diff --git a/YuMi/Modules/YMMessage/View/Session/SessionViewController.m b/YuMi/Modules/YMMessage/View/Session/SessionViewController.m index aaadefcc..0e07b7fe 100644 --- a/YuMi/Modules/YMMessage/View/Session/SessionViewController.m +++ b/YuMi/Modules/YMMessage/View/Session/SessionViewController.m @@ -1194,14 +1194,16 @@ [YYUtility checkAssetsLibrayAvailable:^{ @kStrongify(self); [TZImagePickerConfig sharedInstance].allowPickingImage = YES; - dispatch_async(dispatch_get_global_queue(0, 0), ^{ + dispatch_async(dispatch_get_global_queue(0, 0), + ^{ [[TZImageManager manager] getCameraRollAlbumWithFetchAssets:NO completion:^(TZAlbumModel *model) { [[TZImageManager manager] getAssetsFromFetchResult:model.result completion:^(NSArray *models) { - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_main_queue(), + ^{ NSMutableArray * array = [NSMutableArray array]; if (models.count > 40) { - for (int i = 0; i < 40; i++) { - TZAssetModel * assets = [models objectAtIndex:i]; + for (int i = 0; i < 40; i++) { + TZAssetModel * assets = [models xpSafeObjectAtIndex:i]; QPhotoImageModel * infor = [[QPhotoImageModel alloc] init]; infor.isOrigin = NO; infor.assetInfo = assets; @@ -1209,7 +1211,7 @@ } } else { for (int i = 0; i < models.count; i++) { - TZAssetModel * assets = [models objectAtIndex:i]; + TZAssetModel * assets = [models xpSafeObjectAtIndex:i]; QPhotoImageModel * infor = [[QPhotoImageModel alloc] init]; infor.isOrigin = NO; infor.assetInfo = assets; diff --git a/YuMi/Modules/YMMessage/View/SessionList/SessionListViewController.m b/YuMi/Modules/YMMessage/View/SessionList/SessionListViewController.m index 1b8b9247..5fcbb7b7 100644 --- a/YuMi/Modules/YMMessage/View/SessionList/SessionListViewController.m +++ b/YuMi/Modules/YMMessage/View/SessionList/SessionListViewController.m @@ -251,7 +251,7 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; totalUnreadCount:(NSInteger)totalUnreadCount { // 清理本地数据 NSUInteger index = [self.recentSessions indexOfObject:recentSession]; - [self.recentSessions removeObjectAtIndex:index]; + [self.recentSessions xpSafeRemoveObjectAtIndex:index]; // 如果删除本地会话后就不允许漫游当前会话,则需要进行一次删除服务器会话的操作 BOOL deleteRemote = NO; diff --git a/YuMi/Modules/YMMine/Api/Api+Mine.h b/YuMi/Modules/YMMine/Api/Api+Mine.h index ccefcd59..f9a7dbe6 100644 --- a/YuMi/Modules/YMMine/Api/Api+Mine.h +++ b/YuMi/Modules/YMMine/Api/Api+Mine.h @@ -156,14 +156,12 @@ NS_ASSUME_NONNULL_BEGIN /// 验证凭据 /// @param complection 完成 -/// @param receipt base 64 recepit /// @param chooseEnv @"true" /// @param chargeRecordId 服务端生成的订单编号 /// @param transcationId 内购的唯一标识符 /// @param uid 用户uid /// @param ticket ticket + (void)checkReceipt:(HttpRequestHelperCompletion)complection - chooseEnv:(NSString *)chooseEnv chargeRecordId:(NSString *)chargeRecordId transcationId:(NSString *)transcationId diff --git a/YuMi/Modules/YMMine/Api/Api+Mine.m b/YuMi/Modules/YMMine/Api/Api+Mine.m index 4b5bdc2c..b2cee3ac 100644 --- a/YuMi/Modules/YMMine/Api/Api+Mine.m +++ b/YuMi/Modules/YMMine/Api/Api+Mine.m @@ -526,4 +526,11 @@ __FUNCTION__, pageNo, pageSize]; } ++ (void)medalMine:(HttpRequestHelperCompletion)completion pageNo:(NSNumber *)pageNo pageSize:(NSNumber *)pageSize uid:(NSNumber *)uid type:(NSNumber *)type { + [self makeRequest:@"medal/mine" + method:HttpRequestHelperMethodGET + completion:completion, + __FUNCTION__, pageNo, pageSize, uid, type]; +} + @end diff --git a/YuMi/Modules/YMMine/Model/RecordIncome/XPIncomeRecordGoldDetailsModel.h b/YuMi/Modules/YMMine/Model/RecordIncome/XPIncomeRecordGoldDetailsModel.h index ac77e2d6..a0a054c4 100644 --- a/YuMi/Modules/YMMine/Model/RecordIncome/XPIncomeRecordGoldDetailsModel.h +++ b/YuMi/Modules/YMMine/Model/RecordIncome/XPIncomeRecordGoldDetailsModel.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,copy) NSArray *hallMember; @end -NS_ASSUME_NONNULL_END + @interface XPIncomeRecordGoldDetailItemModel : PIBaseModel @@ -39,3 +39,5 @@ NS_ASSUME_NONNULL_END @property (nonatomic,copy) NSString *ownerAvatar; @end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m b/YuMi/Modules/YMMine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m index 31947dd8..de9356ad 100644 --- a/YuMi/Modules/YMMine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m +++ b/YuMi/Modules/YMMine/View/Cell/MineInfo/XPMineUserInfoEditTableViewCell.m @@ -190,10 +190,13 @@ self.thirdPhotoImageView.hidden = YES; for (int i = 0; i < array.count; i++) { NetImageView * imageView = [self.photoViewArray xpSafeObjectAtIndex:i]; - NSString * imageUrl = [array objectAtIndex:i].photoUrl; - if (imageUrl.length > 0) { - imageView.imageUrl = imageUrl; - imageView.hidden = NO; + UserPhoto *photo = [array xpSafeObjectAtIndex:i]; + if (photo) { + NSString *imageUrl = photo.photoUrl; + if (imageUrl.length > 0) { + imageView.imageUrl = imageUrl; + imageView.hidden = NO; + } } } } diff --git a/YuMi/Modules/YMMine/View/SubViews/MineInfo/XPMineUserInfoDateView.m b/YuMi/Modules/YMMine/View/SubViews/MineInfo/XPMineUserInfoDateView.m index 97379165..ae301da0 100644 --- a/YuMi/Modules/YMMine/View/SubViews/MineInfo/XPMineUserInfoDateView.m +++ b/YuMi/Modules/YMMine/View/SubViews/MineInfo/XPMineUserInfoDateView.m @@ -269,7 +269,7 @@ NSArray * timeArray = [timeStr componentsSeparatedByString:@"-"]; NSMutableArray * timeArr = [[NSMutableArray alloc]init]; for (int i = 0; i if(browser.isAvatar == YES){ return [NSURL URLWithString:self.avatarView.imageUrl]; } - NSString * photoUrl = [self.imageUrls objectAtIndex:index]; - return [NSURL URLWithString:photoUrl]; + NSString *photoUrl = [self.imageUrls xpSafeObjectAtIndex:index]; + return [NSURL URLWithString:photoUrl ? photoUrl : @""]; } - (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index { @@ -670,7 +670,7 @@ HWDMP4PlayDelegate> #pragma mark - SDCycleScrollViewDelegate -(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index { [self.pageButton setTitle:[NSString stringWithFormat:@"%ld/%lu",(index + 1), (unsigned long)self.imageUrls.count] forState:UIControlStateNormal]; - UserPhoto * photo = [self.userPhotoArray objectAtIndex:index]; + UserPhoto * photo = [self.userPhotoArray xpSafeObjectAtIndex:index]; self.reviewIcon.hidden = !photo.isReview; } @@ -840,7 +840,7 @@ HWDMP4PlayDelegate> } if (self.userInfo.privatePhoto.count > 0) { for (int i = 0; i < self.userInfo.privatePhoto.count; i++) { - UserPhoto * photo = [self.userInfo.privatePhoto objectAtIndex:i]; + UserPhoto * photo = [self.userInfo.privatePhoto xpSafeObjectAtIndex:i]; if (photo.photoUrl.length > 0) { [self.userPhotoArray addObject:photo]; [imageUrls addObject:photo.photoUrl]; @@ -854,7 +854,10 @@ HWDMP4PlayDelegate> [self.pageButton setTitle:[NSString stringWithFormat:@"1/%lu",(unsigned long)imageUrls.count] forState:UIControlStateNormal];; // 要初始化一下当前的审核状态 if(self.userPhotoArray.count > 0){ - self.reviewIcon.hidden = ![self.userPhotoArray objectAtIndex:0].isReview; + UserPhoto * photo = [self.userPhotoArray xpSafeObjectAtIndex:0]; + if (photo) { + self.reviewIcon.hidden = !photo.isReview; + } } } diff --git a/YuMi/Modules/YMMonents/View/XPMomentsMineViewController.m b/YuMi/Modules/YMMonents/View/XPMomentsMineViewController.m index e6faa6ec..877f0c01 100644 --- a/YuMi/Modules/YMMonents/View/XPMomentsMineViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMomentsMineViewController.m @@ -194,6 +194,9 @@ } } +- (void)requesstShieldingSuccess:(NSString *)monentsInfo { + +} #pragma mark - JXPagingViewListViewDelegate - (UIScrollView *)listScrollView { diff --git a/YuMi/Modules/YMMonents/View/XPMonentsPublishViewController.m b/YuMi/Modules/YMMonents/View/XPMonentsPublishViewController.m index 5055a745..b1e28d49 100644 --- a/YuMi/Modules/YMMonents/View/XPMonentsPublishViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMonentsPublishViewController.m @@ -265,11 +265,11 @@ - (void)XPMonentsPublishCollectionViewCell:(XPMonentsPublishCollectionViewCell *)view didDeleteItem:(UIImage *)image { [TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsPublishViewController1") confirmHandler:^{ if ([self.datasource containsObject:image]) { - [self.datasource removeObject:image]; + [self.datasource xpSafeRemoveObject:image]; } NSIndexPath * indexPath = [self.collectionView indexPathForCell:view]; if (indexPath.row < self.originAssets.count) { - [self.originAssets removeObjectAtIndex:indexPath.row]; + [self.originAssets xpSafeRemoveObjectAtIndex:indexPath.row]; } [self.collectionView reloadData]; diff --git a/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.m b/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.m index e3aa6f3f..7f1f42e1 100644 --- a/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.m +++ b/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.m @@ -48,14 +48,14 @@ [menu sendCompleted]; } errorToast:NO] uid:uid type:@"1"]; -// [Api requestCurrentResourceListCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) { -// NSArray *list = [PIHomeItemModel modelsWithArray:data.data]; -// [menu sendNext:list]; -// [menu sendCompleted]; -// }fail:^(NSInteger code, NSString * _Nullable msg) { -// [menu sendError:nil]; -// [menu sendCompleted]; -// }]]; + [Api requestCurrentResourceListCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + NSArray *list = [PIHomeItemModel modelsWithArray:data.data]; + [menu sendNext:list]; + [menu sendCompleted]; + }fail:^(NSInteger code, NSString * _Nullable msg) { + [menu sendError:nil]; + [menu sendCompleted]; + }]]; } //- (void)getHomeAllTopsData { diff --git a/YuMi/Modules/YMNewHome/View/Cell/XPNewHomeRecommendTableViewCell.m b/YuMi/Modules/YMNewHome/View/Cell/XPNewHomeRecommendTableViewCell.m index 6f2fbe4a..c44803ba 100644 --- a/YuMi/Modules/YMNewHome/View/Cell/XPNewHomeRecommendTableViewCell.m +++ b/YuMi/Modules/YMNewHome/View/Cell/XPNewHomeRecommendTableViewCell.m @@ -210,7 +210,7 @@ /// @param cycleScrollView cycleScrollView description /// @param index 索引 - (GKCycleScrollViewCell *)cycleScrollView:(GKCycleScrollView *)cycleScrollView cellForViewAtIndex:(NSInteger)index { - XPCycleScrollViewCell * cell = cycleScrollView.dequeueReusableCell; + XPCycleScrollViewCell *cell = (XPCycleScrollViewCell*)cycleScrollView.dequeueReusableCell; if (!cell) { cell = [[XPCycleScrollViewCell alloc] init]; } diff --git a/YuMi/Modules/YMNewHome/View/Search/Presenter/XPInRoomRecordPresenter.m b/YuMi/Modules/YMNewHome/View/Search/Presenter/XPInRoomRecordPresenter.m index 17ccfec9..bda77018 100644 --- a/YuMi/Modules/YMNewHome/View/Search/Presenter/XPInRoomRecordPresenter.m +++ b/YuMi/Modules/YMNewHome/View/Search/Presenter/XPInRoomRecordPresenter.m @@ -33,7 +33,7 @@ [Api requestCleanFootPrint:[self createHttpCompletion:^(BaseModel * _Nonnull data) { @kStrongify(self); [[self getView] cleanInRoomRecordSuccess]; - }] uid:uid roomUid:NULL]; + }] uid:uid roomUid:@""]; } ///大家都在搜 diff --git a/YuMi/Modules/YMNewHome/View/Search/View/XPRoomSearchContainerViewController.m b/YuMi/Modules/YMNewHome/View/Search/View/XPRoomSearchContainerViewController.m index 336efcd0..ce5dd383 100644 --- a/YuMi/Modules/YMNewHome/View/Search/View/XPRoomSearchContainerViewController.m +++ b/YuMi/Modules/YMNewHome/View/Search/View/XPRoomSearchContainerViewController.m @@ -49,6 +49,9 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; @implementation XPRoomSearchContainerViewController +- (void)searchRoomSuccess:(NSArray *)data type:(NSString *)type { + +} - (XPHomeSearchPresenter *)createPresenter { return [[XPHomeSearchPresenter alloc] init]; diff --git a/YuMi/Modules/YMRTC/RtcImpl/TRTCRtcImpl.m b/YuMi/Modules/YMRTC/RtcImpl/TRTCRtcImpl.m index d1715215..49b314f5 100644 --- a/YuMi/Modules/YMRTC/RtcImpl/TRTCRtcImpl.m +++ b/YuMi/Modules/YMRTC/RtcImpl/TRTCRtcImpl.m @@ -28,16 +28,20 @@ self = [super initWithDelegate:delegate]; if (self) { _engine = [TRTCCloud sharedInstance]; - [_engine enableAudioVolumeEvaluation:900]; + TRTCAudioVolumeEvaluateParams *AudioVolumeParams = [[TRTCAudioVolumeEvaluateParams alloc] init]; + AudioVolumeParams.interval = 300; + AudioVolumeParams.enableVadDetection = YES; + AudioVolumeParams.enablePitchCalculation = YES; + AudioVolumeParams.enableSpectrumCalculation = YES; + [self.engine enableAudioVolumeEvaluation:900 withParams:AudioVolumeParams]; [TRTCCloud setConsoleEnabled:NO]; - _engine.delegate = self; + [_engine addDelegate:self]; } return self; } #pragma mark - RtcInterface impl - (BOOL)joinChannel:(NSString *)channelId sign:(nonnull NSString *)sign completion:(void (^)(void))completion { - [self.engine enableAudioVolumeEvaluation:900]; TRTCParams *params = [[TRTCParams alloc] init]; UInt32 appId; NSString *curTtcKey = [[NSUserDefaults standardUserDefaults]valueForKey:@"kTrtcAppId"]; @@ -118,7 +122,8 @@ NSString *aecString = @"{\"api\":\"enableAudioAEC\",\"params\":{\"enable\":1,\"level\":100}}"; [self.engine callExperimentalAPI:aecString]; [self.engine startLocalAudio:TRTCAudioQualityDefault]; - [self.engine.getDeviceManager setSystemVolumeType:TXSystemVolumeTypeMedia]; +// [self.engine.getDeviceManager setSystemVolumeType:TXSystemVolumeTypeMedia]; + [[TRTCCloud sharedInstance] startLocalAudio:TRTCAudioQualityDefault]; } else { [self.engine stopLocalAudio]; @@ -147,7 +152,8 @@ } - (void)destory { - [TRTCCloud destroySharedIntance]; + [TRTCCloud destroySharedInstance]; + [self.engine removeDelegate:self]; } /// 播放背景音乐 diff --git a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.m b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.m index a56b8920..45d819eb 100644 --- a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.m +++ b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.m @@ -139,7 +139,7 @@ NSString *url_1 = @""; NSString *url_2 = @""; id obj = self.boomEventsQueue.firstObject; - [self.boomEventsQueue removeObjectAtIndex:0]; + [self.boomEventsQueue xpSafeRemoveObjectAtIndex:0]; if ([obj isKindOfClass:[AttachmentModel class]]) { Boom632Model *m = [Boom632Model modelWithJSON:[(AttachmentModel *)obj data]]; if ([XPSkillCardPlayerManager shareInstance].roomUid.integerValue != m.roomUid) { @@ -167,7 +167,7 @@ } self.isGifting = YES; id obj = self.giftEventsQueue.firstObject; - [self.giftEventsQueue removeObjectAtIndex:0]; + [self.giftEventsQueue xpSafeRemoveObjectAtIndex:0]; [self handleBoomGiftUpdate:obj]; } else { self.isBooming = NO; @@ -188,7 +188,7 @@ if (self.bannerEventsQueue.count > 0) { self.isBannering = YES; id obj = self.bannerEventsQueue.firstObject; - [self.bannerEventsQueue removeObjectAtIndex:0]; + [self.bannerEventsQueue xpSafeRemoveObjectAtIndex:0]; [self handleBannerUpdate:obj]; } } diff --git a/YuMi/Modules/YMRoom/View/AnimationView/GiftAnimationManager.m b/YuMi/Modules/YMRoom/View/AnimationView/GiftAnimationManager.m index cb2d36ef..0e688c72 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/GiftAnimationManager.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/GiftAnimationManager.m @@ -88,7 +88,7 @@ // 安全地移除第一个元素 dispatch_async(self.queue, ^{ if (self.giftQueue.count > 0) { - [self.giftQueue removeObjectAtIndex:0]; + [self.giftQueue xpSafeRemoveObjectAtIndex:0]; } }); diff --git a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m index 4a14e7a7..43009588 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m @@ -288,6 +288,7 @@ XPRoomGraffitiGiftAnimationViewDelegate ///自己的隐身进房提示 - (void)createEnterHideAnimation { NSDictionary * dic= @{@"title":@"隐身进房", + @"isMe":@"", @"experLevelSeq":@"", @"effectPath" : @""}; [self.enterRoomAnimationQueue addObject:dic]; @@ -315,7 +316,9 @@ XPRoomGraffitiGiftAnimationViewDelegate // 取出队列头部的动画信息并移除 NSDictionary *dic = [self.enterRoomAnimationQueue firstObject]; - [self.enterRoomAnimationQueue removeObjectAtIndex:0]; + if (self.enterRoomAnimationQueue.count > 0) { + [self.enterRoomAnimationQueue xpSafeRemoveObjectAtIndex:0]; + } NSString *title = [dic objectForKey:@"title"]; if ([title isEqualToString:@"隐身进房"]) { @@ -526,7 +529,9 @@ XPRoomGraffitiGiftAnimationViewDelegate // 从队列中取出第一个元素并移出队列 AttachmentModel *nextAttachment = [self.roomBannertModelsQueueV2 firstObject]; - [self.roomBannertModelsQueueV2 removeObjectAtIndex:0]; + if (self.roomBannertModelsQueueV2.count > 0) { + [self.roomBannertModelsQueueV2 xpSafeRemoveObjectAtIndex:0]; + } // 设置为正在显示的状态 self.isRoomBannerV2Displaying = YES; @@ -920,7 +925,9 @@ XPRoomGraffitiGiftAnimationViewDelegate - (void)nextCarEffect { if (self.carEffectQueue.count > 0) { - [self.carEffectQueue removeObjectAtIndex:0]; + if (self.carEffectQueue.count > 0) { + [self.carEffectQueue xpSafeRemoveObjectAtIndex:0]; + } } if (self.carEffectQueue.count > 0) { [self playCarEffect:self.carEffectQueue.firstObject]; @@ -1552,7 +1559,7 @@ XPRoomGraffitiGiftAnimationViewDelegate } if (model.enterHide) { //隐身进房 - if ([message.from isEqualToString:[AccountInfoStorage instance].getUid]) { + if (model.uid == [AccountInfoStorage instance].getUid.integerValue) { [self createEnterHideAnimation]; } } else { @@ -2268,7 +2275,9 @@ XPRoomGraffitiGiftAnimationViewDelegate - (void)removeFromSvgaQueueAtIndex:(NSInteger)index { dispatch_async(self.giftEffectsQueue, ^{ if (index < self.svgaQueue.count) { - [self.svgaQueue removeObjectAtIndex:index]; + if (index < self.svgaQueue.count) { + [self.svgaQueue xpSafeRemoveObjectAtIndex:index]; + } } }); } @@ -2404,7 +2413,7 @@ XPRoomGraffitiGiftAnimationViewDelegate [tarrowVeiw removeFromSuperview]; self.isPlayOfB = NO; if (self.animationListB.count > 0) { - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; } @@ -2455,7 +2464,7 @@ XPRoomGraffitiGiftAnimationViewDelegate if (finished) { [luckyGiftEffectView removeFromSuperview]; if (self.animationListB.count > 0) { - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } self.isPlayOfB = NO; [self playAnimationWithModel]; @@ -2510,7 +2519,7 @@ XPRoomGraffitiGiftAnimationViewDelegate [candyTreeView removeFromSuperview]; self.isPlayOfB = NO; if (self.animationListB.count > 0) { - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; } @@ -2566,7 +2575,7 @@ XPRoomGraffitiGiftAnimationViewDelegate self.isPlayOfB = NO; [nobleLevelUpView removeFromSuperview]; if (self.animationListB.count > 0) { - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; } @@ -2620,7 +2629,7 @@ XPRoomGraffitiGiftAnimationViewDelegate self.isPlayOfB = NO; if(self.animationListB.count > 0){ - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; } @@ -2658,7 +2667,7 @@ XPRoomGraffitiGiftAnimationViewDelegate [anchorRankView removeFromSuperview]; self.isPlayOfB = NO; if(self.animationListB.count > 0){ - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; [self playAnimationWithModel]; } }]; @@ -2730,7 +2739,7 @@ XPRoomGraffitiGiftAnimationViewDelegate [treasureView removeFromSuperview]; self.isPlayOfB = NO; if (self.animationListB.count > 0) { - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; } @@ -2784,7 +2793,7 @@ XPRoomGraffitiGiftAnimationViewDelegate [tarrowVeiw removeFromSuperview]; self.isPlayOfB = NO; if (self.animationListB.count > 0) { - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; } @@ -2821,7 +2830,7 @@ XPRoomGraffitiGiftAnimationViewDelegate [compoundGiftView removeFromSuperview]; self.isPlayOfB = NO; if(self.animationListB.count > 0){ - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; } @@ -2860,7 +2869,7 @@ XPRoomGraffitiGiftAnimationViewDelegate [bannerView removeFromSuperview]; self.isPlayOfB = NO; if(self.animationListB.count > 0){ - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; }]; @@ -2887,7 +2896,7 @@ XPRoomGraffitiGiftAnimationViewDelegate [bannerView removeFromSuperview]; self.isPlayOfB = NO; if(self.animationListB.count > 0){ - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; }]; @@ -2931,7 +2940,7 @@ XPRoomGraffitiGiftAnimationViewDelegate [self.universalBannerViewCaches removeObject:bannerView]; self.isPlayOfB = NO; if(self.animationListB.count > 0){ - [self.animationListB removeObjectAtIndex:0]; + [self.animationListB xpSafeRemoveObjectAtIndex:0]; } [self playAnimationWithModel]; } @@ -3116,7 +3125,7 @@ XPRoomGraffitiGiftAnimationViewDelegate if (finished) { [sailingView removeFromSuperview]; if (self.sailingQueue.count > 0) { - [self.sailingQueue removeObjectAtIndex:0]; + [self.sailingQueue xpSafeRemoveObjectAtIndex:0]; } if (self.sailingQueue.count > 0) { [self createSailingBannerAnimation:self.sailingQueue.firstObject]; diff --git a/YuMi/Modules/YMRoom/View/ArrangeMic/View/Cell/XPArrangeMicTableViewCell.m b/YuMi/Modules/YMRoom/View/ArrangeMic/View/Cell/XPArrangeMicTableViewCell.m index 832351ac..945eb33c 100644 --- a/YuMi/Modules/YMRoom/View/ArrangeMic/View/Cell/XPArrangeMicTableViewCell.m +++ b/YuMi/Modules/YMRoom/View/ArrangeMic/View/Cell/XPArrangeMicTableViewCell.m @@ -64,6 +64,7 @@ [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(self.avaratImageView.mas_trailing).offset(10); make.centerY.mas_equalTo(self.contentView); +// make.width.mas_lessThanOrEqualTo(KScreenWidth - 20 - 30 - 75); }]; [self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) { @@ -77,6 +78,7 @@ make.height.mas_equalTo(25); make.trailing.mas_equalTo(self.contentView).offset(-15); make.centerY.mas_equalTo(self.contentView); + make.leading.mas_greaterThanOrEqualTo(self.sexImageView.mas_trailing).offset(2); }]; } @@ -92,9 +94,6 @@ _userInfo = userInfo; if (_userInfo) { NSString * nick = _userInfo.nick; - if (nick.length > 6) { - nick = [nick substringToIndex:6]; - } self.nameLabel.text= nick; self.avaratImageView.imageUrl = _userInfo.avatar; [self.sexImageView setTitle:[NSString getAgeWithBirth:_userInfo.birth] forState:UIControlStateNormal]; diff --git a/YuMi/Modules/YMRoom/View/ArrangeMic/View/XPArrangeMicViewController.m b/YuMi/Modules/YMRoom/View/ArrangeMic/View/XPArrangeMicViewController.m index 212349c7..9508f599 100644 --- a/YuMi/Modules/YMRoom/View/ArrangeMic/View/XPArrangeMicViewController.m +++ b/YuMi/Modules/YMRoom/View/ArrangeMic/View/XPArrangeMicViewController.m @@ -135,11 +135,14 @@ #pragma mark - Private Method - (void)configDefaultData { - if (self.userInfo.isManager) { - [self.applyButton setTitle:YMLocalizedString(@"XPArrangeMicViewController1") forState:UIControlStateNormal]; - } else { - [self.applyButton setTitle:YMLocalizedString(@"XPArrangeMicViewController2") forState:UIControlStateNormal]; - } +#if DEBUG + self.userInfo.isManager = NO; +#endif + if (self.userInfo.isManager) { + [self.applyButton setTitle:YMLocalizedString(@"XPArrangeMicViewController1") forState:UIControlStateNormal]; + } else { + [self.applyButton setTitle:YMLocalizedString(@"XPArrangeMicViewController2") forState:UIControlStateNormal]; + } if (self.userInfo.type == ArrangeMicType_Dating) { self.femaleButton.hidden = self.userInfo.isManager; @@ -660,6 +663,9 @@ #pragma mark - Event Response - (void)applyButtonAction:(UIButton *)sender { +#if DEBUG + self.userInfo.isManager = NO; +#endif if (self.userInfo.isManager) { XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"]; XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagLine title:@"Line" imageName:@"share_line" disableImageName:@"share_line"]; diff --git a/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.m index 4cab8be4..47a5863a 100644 --- a/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -1442,7 +1442,7 @@ if (self.trumpetQueue.count) { dispatch_sync(dispatch_get_main_queue(), ^{ [self createTrumpetAnimation:self.trumpetQueue.firstObject]; - [self.trumpetQueue removeObjectAtIndex:0]; + [self.trumpetQueue xpSafeRemoveObjectAtIndex:0]; }); } else { dispatch_sync(dispatch_get_main_queue(), ^{ diff --git a/YuMi/Modules/YMRoom/View/LuckyPackage/LuckyPackageLogicManager.m b/YuMi/Modules/YMRoom/View/LuckyPackage/LuckyPackageLogicManager.m index 811c1818..d9752572 100644 --- a/YuMi/Modules/YMRoom/View/LuckyPackage/LuckyPackageLogicManager.m +++ b/YuMi/Modules/YMRoom/View/LuckyPackage/LuckyPackageLogicManager.m @@ -100,7 +100,7 @@ - (void)removeReceivedLuckyPackage { NSMutableArray *array = [self.infoModel.redEnvelopeListVoList mutableCopy]; if (array.count>0) { - [array removeObjectAtIndex:0]; + [array xpSafeRemoveObjectAtIndex:0]; } self.infoModel.redEnvelopeListVoList = array.copy; self.packageNum = self.infoModel.redEnvelopeListVoList.count; @@ -157,8 +157,8 @@ }]; if (count == 0 && index != NSNotFound) { - [self.selectedGiftModels removeObjectAtIndex:index]; - [self.selectedGiftCounts removeObjectAtIndex:index]; + [self.selectedGiftModels xpSafeRemoveObjectAtIndex:index]; + [self.selectedGiftCounts xpSafeRemoveObjectAtIndex:index]; } else { if (index != NSNotFound) { [self.selectedGiftCounts replaceObjectAtIndex:index withObject:@(count)]; diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m index b47e649e..3f5d9efd 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m @@ -281,7 +281,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; - (void)safelyRemoveLocationAtIndex:(NSUInteger)index { if (index < self.locationArray.count) { - [self.locationArray removeObjectAtIndex:index]; + [self.locationArray xpSafeRemoveObjectAtIndex:index]; self.atCount = MAX(0, self.atCount - 1); } } diff --git a/YuMi/Modules/YMRoom/View/RoomPhotoAlbum/View/PIRoomPhotoAlbumItemVC.m b/YuMi/Modules/YMRoom/View/RoomPhotoAlbum/View/PIRoomPhotoAlbumItemVC.m index 91875cf6..0c7f819e 100644 --- a/YuMi/Modules/YMRoom/View/RoomPhotoAlbum/View/PIRoomPhotoAlbumItemVC.m +++ b/YuMi/Modules/YMRoom/View/RoomPhotoAlbum/View/PIRoomPhotoAlbumItemVC.m @@ -167,7 +167,7 @@ } } if(self.photoList.count > 0){ - [self.photoList removeObjectAtIndex:index]; + [self.photoList xpSafeRemoveObjectAtIndex:index]; [self.collectionView reloadData]; } } @@ -248,8 +248,8 @@ } ///删除图片 -(void)delPhotoWidthIndex:(NSInteger)index{ - [self.datasource removeObjectAtIndex:index]; - [self.originAssets removeObjectAtIndex:index]; + [self.datasource xpSafeRemoveObjectAtIndex:index]; + [self.originAssets xpSafeRemoveObjectAtIndex:index]; } ///返回,需要清空图片 -(void)cleanPhotoList{ diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/GiftComboManager.m b/YuMi/Modules/YMRoom/View/SendGiftView/GiftComboManager.m index e20ecbd2..ffc07559 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/GiftComboManager.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/GiftComboManager.m @@ -213,7 +213,7 @@ } GiftReceiveInfoModel *receiveInfo = [self.giftComboQueue firstObject]; - [self.giftComboQueue removeObjectAtIndex:0]; + [self.giftComboQueue xpSafeRemoveObjectAtIndex:0]; dispatch_async(dispatch_get_main_queue(), ^{ [self handleGiftInfo:receiveInfo]; }); @@ -377,7 +377,7 @@ if (self.giftComboQueue.count > 0) { // 获取并移除队列中的第一个元数据 AttachmentModel *attachment = [self.giftComboQueue firstObject]; - [self.giftComboQueue removeObjectAtIndex:0]; + [self.giftComboQueue xpSafeRemoveObjectAtIndex:0]; // 处理逻辑 [self processGiftComboWith:attachment]; diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m index 7d2adaf3..e6fa23ec 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m @@ -273,7 +273,7 @@ @synchronized (self.updateGoldQueue) { if (self.updateGoldQueue.count > 0) { NSString *goldString = [self.updateGoldQueue firstObject]; - [self.updateGoldQueue removeObjectAtIndex:0]; + [self.updateGoldQueue xpSafeRemoveObjectAtIndex:0]; return goldString; } return @""; diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m index 673665b5..dbdd0a94 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m @@ -981,10 +981,12 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; for (int i = 0 ; i < self.packGiftList.count; i++) { GiftInfoModel *infoModel = self.packGiftList[i]; if(infoModel.giftId == self.freeModel.giftId.integerValue){ - [giftArray removeObjectAtIndex:i]; - [giftArray insertObject:infoModel atIndex:0]; - isHaveFreeGift = YES; - break; + if (i < giftArray.count) { + [giftArray xpSafeRemoveObjectAtIndex:i]; + [giftArray xpSafeInsertObject:infoModel atIndex:0]; + isHaveFreeGift = YES; + break; + } } } if(isHaveFreeGift == NO && self.freeModel.curStage != nil && self.freeModel.curStage.integerValue == 0 ){ diff --git a/YuMi/Structure/PrefixHeader.pch b/YuMi/Structure/PrefixHeader.pch index 279f6b2e..fe3dd309 100644 --- a/YuMi/Structure/PrefixHeader.pch +++ b/YuMi/Structure/PrefixHeader.pch @@ -30,6 +30,7 @@ isEnterprise = [bundleID isEqualToString:@"com.hflighting.yumi"];\ #import "YUMIMacroUitls.h" #import #import "NSArray+Safe.h" +#import "NSMutableArray+Safe.h" #import "UIImage+Utils.h" #import "XNDJTDDLoadingTool.h" #import "DJDKMIMOMColor.h" diff --git a/YuMi/Tools/Safe/NSMutableArray+Safe.h b/YuMi/Tools/Safe/NSMutableArray+Safe.h new file mode 100644 index 00000000..1894935f --- /dev/null +++ b/YuMi/Tools/Safe/NSMutableArray+Safe.h @@ -0,0 +1,64 @@ +// +// NSMutableArray+Safe.h +// YUMI +// +// Created by YUMI on 2023/11/15. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSMutableArray (Safe) + +/** + 安全地从数组中移除指定索引的对象 + 如果索引超出范围,则不执行任何操作 + + @param index 要移除的对象的索引 + */ +- (void)xpSafeRemoveObjectAtIndex:(NSUInteger)index; + +/** + 安全地从数组中移除指定的对象 + 如果对象不存在,则不执行任何操作 + + @param anObject 要移除的对象 + */ +- (void)xpSafeRemoveObject:(id)anObject; + +/** + 安全地从数组中移除指定索引集合中的对象 + 如果索引集合中的任何索引超出范围,则跳过该索引 + + @param indexes 要移除的对象的索引集合 + */ +- (void)xpSafeRemoveObjectsAtIndexes:(NSIndexSet *)indexes; + +/** + 安全地在指定索引处插入对象 + 如果索引超出范围,则不执行任何操作或在末尾添加(取决于索引) + + @param anObject 要插入的对象 + @param index 要插入的位置 + */ +- (void)xpSafeInsertObject:(id)anObject atIndex:(NSUInteger)index; + +/** + 安全地替换指定索引处的对象 + 如果索引超出范围,则不执行任何操作 + + @param index 要替换的对象的索引 + @param anObject 替换的对象 + */ +- (void)xpSafeReplaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject; + +/** + 安全地移除数组中的所有对象 + 如果数组为空,则不执行任何操作 + */ +- (void)xpSafeRemoveAllObjects; + +@end + +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/YuMi/Tools/Safe/NSMutableArray+Safe.m b/YuMi/Tools/Safe/NSMutableArray+Safe.m new file mode 100644 index 00000000..e024538d --- /dev/null +++ b/YuMi/Tools/Safe/NSMutableArray+Safe.m @@ -0,0 +1,69 @@ +// +// NSMutableArray+Safe.m +// YUMI +// +// Created by YUMI on 2023/11/15. +// + +#import "NSMutableArray+Safe.h" + +@implementation NSMutableArray (Safe) + +- (void)xpSafeRemoveObjectAtIndex:(NSUInteger)index { + if ([self isKindOfClass:[NSMutableArray class]]) { + if (self.count > 0 && index < self.count) { + [self removeObjectAtIndex:index]; + } + } +} + +- (void)xpSafeRemoveObject:(id)anObject { + if ([self isKindOfClass:[NSMutableArray class]]) { + if (anObject && [self containsObject:anObject]) { + [self removeObject:anObject]; + } + } +} + +- (void)xpSafeRemoveObjectsAtIndexes:(NSIndexSet *)indexes { + if ([self isKindOfClass:[NSMutableArray class]] && indexes) { + // 创建一个有效索引的集合 + NSMutableIndexSet *validIndexes = [NSMutableIndexSet indexSet]; + [indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) { + if (idx < self.count) { + [validIndexes addIndex:idx]; + } + }]; + + if (validIndexes.count > 0) { + [self removeObjectsAtIndexes:validIndexes]; + } + } +} + +- (void)xpSafeInsertObject:(id)anObject atIndex:(NSUInteger)index { + if ([self isKindOfClass:[NSMutableArray class]] && anObject) { + if (index <= self.count) { + [self insertObject:anObject atIndex:index]; + } else if (index > self.count) { + // 如果索引超出范围,则添加到末尾 + [self addObject:anObject]; + } + } +} + +- (void)xpSafeReplaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject { + if ([self isKindOfClass:[NSMutableArray class]] && anObject) { + if (index < self.count) { + [self replaceObjectAtIndex:index withObject:anObject]; + } + } +} + +- (void)xpSafeRemoveAllObjects { + if ([self isKindOfClass:[NSMutableArray class]] && self.count > 0) { + [self removeAllObjects]; + } +} + +@end \ No newline at end of file diff --git a/YuMi/Tools/sdkContent/content/NetListen(网络监听)/RealTime(实时)/BSRealTimeView.m b/YuMi/Tools/sdkContent/content/NetListen(网络监听)/RealTime(实时)/BSRealTimeView.m index f106f73d..6099bace 100644 --- a/YuMi/Tools/sdkContent/content/NetListen(网络监听)/RealTime(实时)/BSRealTimeView.m +++ b/YuMi/Tools/sdkContent/content/NetListen(网络监听)/RealTime(实时)/BSRealTimeView.m @@ -557,8 +557,10 @@ @kWeakify(self) UITableViewRowAction * deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"置頂" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) { @kStrongify(self) - [ self.dataArr removeObjectAtIndex:indexPath.row]; - [self.tableView reloadData]; + if (indexPath.row < self.dataArr.count) { + [self.dataArr xpSafeRemoveObjectAtIndex:indexPath.row]; + [self.tableView reloadData]; + } }]; deleteAction.title = @"刪除"; deleteAction.backgroundColor = [UIColor redColor];