新增pag动效及首页bug修复
This commit is contained in:
@@ -43,8 +43,9 @@
|
||||
///P
|
||||
#import "XPNewHomeRecommendPresenter.h"
|
||||
#import "XPNewHomeRecommendProtocol.h"
|
||||
#import "XPHomeGameView.h"
|
||||
UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
@interface XPHomeRecommendViewController ()<UITableViewDelegate, UITableViewDataSource, XPNewHomePlayTableViewCellDelegate, XPHomeBannerTableViewCellDelegate,XPNewHomeRecommendTableViewCellDelegate,XPNewHomeRecommendProtocol,XPNewHomePartyTableViewCellDelegate,CountDownHelperDelegate>
|
||||
@interface XPHomeRecommendViewController ()<UITableViewDelegate, UITableViewDataSource, XPNewHomePlayTableViewCellDelegate, XPHomeBannerTableViewCellDelegate,XPNewHomeRecommendTableViewCellDelegate,XPNewHomeRecommendProtocol,XPNewHomePartyTableViewCellDelegate,CountDownHelperDelegate,XPNewHomePlayEmptyTableViewCellDelegate,XPHomeGameViewDelegate>
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
|
||||
@@ -63,6 +64,8 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
@property(nonatomic,strong)XPNewHomePartyTableViewCell *cell;
|
||||
///正在播放声音的cell在UITableView的Y坐标
|
||||
@property(nonatomic,assign) CGFloat cellY;
|
||||
///游戏列表
|
||||
@property (nonatomic, strong) NSMutableArray<LittleGameInfoModel *> *littleGameArray;
|
||||
@end
|
||||
|
||||
@implementation XPHomeRecommendViewController
|
||||
@@ -138,7 +141,12 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
[self.presenter getFriendListWithGroup:group];
|
||||
|
||||
});
|
||||
|
||||
dispatch_group_enter(group);
|
||||
dispatch_group_async(group, queue, ^{
|
||||
|
||||
[self.presenter getLittleGameListWithGroup:group];
|
||||
|
||||
});
|
||||
|
||||
dispatch_group_notify(group,dispatch_get_main_queue(), ^{
|
||||
self.isRequestData = NO;
|
||||
@@ -176,14 +184,14 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
return 2;
|
||||
}
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
if(section == 0)return self.playTeamList.count > 0 ? 1 : 0;
|
||||
if(section == 0) return 1;
|
||||
return self.personalRoomList.count > 0 ? self.personalRoomList.count : 1;
|
||||
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (indexPath.section == 0) {
|
||||
return kGetScaleWidth(102);
|
||||
return self.playTeamList.count > 0 ? kGetScaleWidth(102) : kGetScaleWidth(75);
|
||||
}
|
||||
return self.personalRoomList.count > 0 ? kGetScaleWidth(104) : 300;
|
||||
|
||||
@@ -191,30 +199,32 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if(indexPath.section == 0) {
|
||||
XPNewHomePlayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
|
||||
if (cell == nil) {
|
||||
cell = [[XPNewHomePlayTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
|
||||
if(self.playTeamList.count > 0){
|
||||
XPNewHomePlayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
|
||||
if (cell == nil) {
|
||||
cell = [[XPNewHomePlayTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
|
||||
}
|
||||
|
||||
|
||||
cell.playRoomList = self.playTeamList;
|
||||
|
||||
cell.delegate = self;
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
cell.playRoomList = self.playTeamList;
|
||||
|
||||
cell.delegate = self;
|
||||
return cell;
|
||||
|
||||
}
|
||||
|
||||
if(self.personalRoomList.count == 0){
|
||||
XPNewHomePlayEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
|
||||
if (cell == nil) {
|
||||
cell = [[XPNewHomePlayEmptyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
|
||||
}
|
||||
|
||||
[cell setConstraints];
|
||||
[cell setTitle:YMLocalizedString(@"XPGuildEmptyCollectionViewCell0")];
|
||||
|
||||
cell.isClan = YES;
|
||||
cell.delegate = self;
|
||||
return cell;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
XPNewHomePartyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePartyTableViewCell class])];
|
||||
if (cell == nil) {
|
||||
cell = [[XPNewHomePartyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePartyTableViewCell class])];
|
||||
@@ -283,19 +293,79 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
}
|
||||
}
|
||||
- (void)chooseGameAction{
|
||||
// XPHomeGameView *gameView = [XPHomeGameView new];
|
||||
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
||||
// gameView.playGameList = self.littleGameArray;
|
||||
// gameView.delegate = self;
|
||||
// [kWindow addSubview:gameView];
|
||||
// XPHomeGameView *gameView = [XPHomeGameView new];
|
||||
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
||||
// gameView.playGameList = self.littleGameArray;
|
||||
// gameView.delegate = self;
|
||||
// [kWindow addSubview:gameView];
|
||||
}
|
||||
#pragma mark - XPNewHomePlayEmptyTableViewCellDelegate
|
||||
- (void)emptyCellChooseGameAction{
|
||||
// XPHomeGameView *gameView = [XPHomeGameView new];
|
||||
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
||||
// gameView.playGameList = self.littleGameArray;
|
||||
// gameView.delegate = self;
|
||||
// [kWindow addSubview:gameView];
|
||||
// XPHomeGameView *gameView = [XPHomeGameView new];
|
||||
// gameView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
||||
// gameView.playGameList = self.littleGameArray;
|
||||
// gameView.delegate = self;
|
||||
// [kWindow addSubview:gameView];
|
||||
}
|
||||
#pragma mark - XPHomeGameViewDelegate
|
||||
- (void)xpHomeGameViewChooseGameWithGameModel:(LittleGameInfoModel *)gameModel{
|
||||
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
[self showLoading];
|
||||
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data];
|
||||
if(roomInfo.isReselect){
|
||||
[XPRoomViewController openRoom:[AccountInfoStorage instance].getUid mgId:gameModel.mgId viewController:self];
|
||||
}else{
|
||||
[self updateRoomInformation:gameModel roomInfo:roomInfo];
|
||||
}
|
||||
} else {
|
||||
[self hideHUD];
|
||||
[self showErrorToast:msg];
|
||||
}
|
||||
} uid:uid intoUid:uid];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
///更新为游戏房
|
||||
-(void)updateRoomInformation:(LittleGameInfoModel *)gameModel roomInfo:(RoomInfoModel *)roomInfo{
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
NSMutableDictionary * params = [NSMutableDictionary dictionary];
|
||||
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
||||
[params setObject:ticket forKey:@"ticket"];
|
||||
[params setObject:uid forKey:@"uid"];
|
||||
[params setObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"];
|
||||
if (roomInfo.title.length > 0) {
|
||||
[params setObject:roomInfo.title forKey:@"title"];
|
||||
}
|
||||
|
||||
if (roomInfo.roomPwd.length > 0) {
|
||||
[params setObject:roomInfo.roomPwd forKey:@"roomPwd"];
|
||||
} else{
|
||||
[params setObject:@"" forKey:@"roomPwd"];
|
||||
}
|
||||
|
||||
if (roomInfo.tagId > 0) {
|
||||
[params setObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"];
|
||||
}
|
||||
|
||||
[params setObject:@(RoomType_MiniGame) forKey:@"type"];
|
||||
[params setObject:gameModel.mgId forKey:@"mgId"];
|
||||
|
||||
[params setObject:@(roomInfo.hasAnimationEffect) forKey:@"hasAnimationEffect"];
|
||||
@weakify(self)
|
||||
[Api ownerUpdateRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
@strongify(self);
|
||||
[self hideHUD];
|
||||
if (code == 200) {
|
||||
[XPRoomViewController openRoom:[AccountInfoStorage instance].getUid mgId:gameModel.mgId viewController:self];
|
||||
} else {
|
||||
[self showErrorToast:msg];
|
||||
}
|
||||
} params:params];
|
||||
}
|
||||
#pragma mark - XPHomeBannerTableViewCell
|
||||
- (void)xPHomeBannerTableViewCell:(XPHomeBannerTableViewCell *)view didClickBanner:(HomeBannerInfoModel *)info {
|
||||
@@ -351,6 +421,11 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
|
||||
self.personalRoomList = [NSMutableArray arrayWithArray:list];
|
||||
dispatch_group_leave(group);
|
||||
}
|
||||
- (void)onGetLittleGameListSuccess:(NSArray<LittleGameInfoModel *> *)items withGroup:(nonnull dispatch_group_t)group{
|
||||
|
||||
self.littleGameArray = [[NSMutableArray alloc]initWithArray:items];
|
||||
dispatch_group_leave(group);
|
||||
}
|
||||
- (void)getFriendListFailWithGroup:(dispatch_group_t)group{
|
||||
dispatch_group_leave(group);
|
||||
}
|
||||
|
Reference in New Issue
Block a user