首页请求优化
This commit is contained in:
@@ -106,54 +106,39 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
#pragma mark - InitHttp
|
||||
|
||||
-(void)requestData{
|
||||
///正在播放声音,不能刷新数据
|
||||
if(self.pi_playAudioCell != nil){
|
||||
if(self.refreshComplete){
|
||||
self.refreshComplete();
|
||||
}
|
||||
return;
|
||||
}///正在播放声音,不能刷新数据
|
||||
///加锁,防止测试发现偶尔会出现闪退bug
|
||||
@synchronized (self.presenter) {
|
||||
if(self.isRequestData == YES){
|
||||
if(self.refreshComplete){
|
||||
self.refreshComplete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
self.isRequestData = YES;
|
||||
///网络请求异步加载
|
||||
dispatch_group_t group =dispatch_group_create();
|
||||
// 并行队列
|
||||
dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
|
||||
|
||||
|
||||
dispatch_group_enter(group);
|
||||
dispatch_group_async(group, queue, ^{
|
||||
|
||||
[self.presenter getPlayGameWithTeam:1 withGroup:group];
|
||||
|
||||
});
|
||||
dispatch_group_enter(group);
|
||||
dispatch_group_async(group, queue, ^{
|
||||
|
||||
[self.presenter getFriendListWithGroup:group];
|
||||
|
||||
});
|
||||
|
||||
|
||||
dispatch_group_notify(group,dispatch_get_main_queue(), ^{
|
||||
///正在请求数据,不用重新请求
|
||||
if(self.isRequestData == YES){
|
||||
if(self.refreshComplete){
|
||||
self.refreshComplete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
self.isRequestData = YES;
|
||||
[self.presenter getHomeListDataWith:1 completeHandle:^(BOOL isSuccess, NSArray *playGameList, NSArray *friendList) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.isRequestData = NO;
|
||||
if(playGameList.count > 0){
|
||||
self.playTeamList = [NSMutableArray arrayWithArray:playGameList];
|
||||
}
|
||||
if(friendList.count > 0){
|
||||
[self getFriendList:friendList];
|
||||
}
|
||||
if(self.refreshComplete){
|
||||
self.refreshComplete();
|
||||
}
|
||||
if(self.pi_playAudioCell == nil){///播放音频时不能刷新数据
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
- (void)headerRefresh {
|
||||
self.isRequestData = NO;
|
||||
@@ -399,16 +384,8 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
|
||||
|
||||
|
||||
///扩列交友
|
||||
- (void)getPlayGameWithTeamSuccess:(NSArray *)list withGroup:(nonnull dispatch_group_t)group{
|
||||
|
||||
self.playTeamList = [NSMutableArray arrayWithArray:list];
|
||||
dispatch_group_leave(group);
|
||||
}
|
||||
- (void)getHomeRecommendDataFailWithGroup:(dispatch_group_t)group{
|
||||
dispatch_group_leave(group);
|
||||
}
|
||||
- (void)getFriendListSuccess:(NSArray *)list withGroup:(dispatch_group_t)group{
|
||||
|
||||
- (void)getFriendList:(NSArray *)list{
|
||||
|
||||
for (int i = 0;i < list.count;i++) {
|
||||
HomePlayRoomModel *model = list[i];
|
||||
@@ -425,7 +402,7 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
model.labelsWidthList = widthList;
|
||||
}
|
||||
self.personalRoomList = [NSMutableArray arrayWithArray:list];
|
||||
dispatch_group_leave(group);
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - JXPagingViewListViewDelegate
|
||||
|
Reference in New Issue
Block a user