优化
删除不使用的方法 删除/补充不必要的换行 通过 nullable 处理部分警告
This commit is contained in:
@@ -56,9 +56,7 @@ UIKIT_EXTERN NSString * kHomeMoreScrollPageKey;
|
||||
UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
|
||||
@interface XPNewHomeViewController ()<JXPagerViewDelegate,JXPagerMainTableViewGestureDelegate,JXCategoryViewDelegate, XPHomeContainerProtocol, XPNewHomeNavViewDelegate,XPNewHomeHeadViewDelegate,XPHomeRecommendOtherRoomViewDelegate,XPHomeRecommendViewControllerDelegate>
|
||||
{
|
||||
NSTimer * timer;
|
||||
}
|
||||
|
||||
///背景
|
||||
@property (nonatomic,strong) UIImageView *backImageView;
|
||||
///导航
|
||||
@@ -89,12 +87,11 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)dealloc{
|
||||
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
||||
[timer fire];
|
||||
timer = nil;
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)isHiddenNavBar {
|
||||
return YES;
|
||||
}
|
||||
@@ -102,6 +99,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
- (XPHomeContainerPresenter *)createPresenter {
|
||||
return [[XPHomeContainerPresenter alloc] init];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
if(self.isEmpty == NO){
|
||||
@@ -109,27 +107,17 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
[self initHttp];
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
[self addTimer];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
if (timer) {
|
||||
[timer setFireDate:[NSDate distantPast]]; //很远的过去
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
if (timer) {
|
||||
//关闭定时器
|
||||
[timer setFireDate:[NSDate distantFuture]]; //很远的将来
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)tokenInvalid {
|
||||
|
||||
[[AccountInfoStorage instance] saveAccountInfo:nil];
|
||||
@@ -145,15 +133,11 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
}
|
||||
#pragma mark - Private Method
|
||||
- (void)addTimer {
|
||||
@kWeakify(self);
|
||||
timer = [XPWeakTimer scheduledTimerWithTimeInterval:15 block:^(id userInfo) {
|
||||
@kStrongify(self);
|
||||
PIHomeCategoryTitleModel *tagModel = [self.tagModelList safeObjectAtIndex1:self.type];
|
||||
XPHomePartyViewController *homeVC = [self.validListDict objectForKey:[NSNumber numberWithInteger:self.type]];
|
||||
homeVC.tagModel = tagModel;
|
||||
[self.recommendVC headerRefresh];
|
||||
} userInfo:nil repeats:YES];
|
||||
// PIHomeCategoryTitleModel *tagModel = [self.tagModelList safeObjectAtIndex1:self.type];
|
||||
// XPHomePartyViewController *homeVC = [self.validListDict objectForKey:[NSNumber numberWithInteger:self.type]];
|
||||
// homeVC.tagModel = tagModel;
|
||||
}
|
||||
|
||||
- (void)initSubViews {
|
||||
self.type = 0;
|
||||
self.view.backgroundColor = [DJDKMIMOMColor colorWithHexString:@"#F3F5FA"];
|
||||
@@ -189,25 +173,17 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
||||
self.pagingView.mainTableView.mj_header = header;
|
||||
[ClientConfig shareConfig].inviteCode = @"";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[self.pagingView.mainTableView.mj_header beginRefreshing];
|
||||
@kWeakify(self);
|
||||
|
||||
self.recommendVC.refreshComplete = ^{
|
||||
@kStrongify(self);
|
||||
[self.pagingView.mainTableView.mj_header endRefreshing];
|
||||
|
||||
[self.pagingView.mainTableView.mj_header endRefreshing];
|
||||
};
|
||||
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(homeVCRefreshComplete) name:@"khomeVCRefreshComplete" object:nil];
|
||||
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(logOut) name:@"kInLoginVC" object:nil];
|
||||
|
||||
|
||||
}
|
||||
-(void)homeVCRefreshComplete{
|
||||
[self.pagingView.mainTableView.mj_header endRefreshing];
|
||||
@@ -218,15 +194,10 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
}
|
||||
-(void)headerRefresh{
|
||||
[self initHttp];
|
||||
// if(self.titleView.index == self.tagModelList.count - 1){
|
||||
// [self.recommendVC headerRefresh];
|
||||
// }else{
|
||||
PIHomeCategoryTitleModel *tagModel = [self.tagModelList safeObjectAtIndex1:self.type];
|
||||
XPHomePartyViewController *homeVC = [self.validListDict objectForKey:[NSNumber numberWithInteger:self.type]];
|
||||
homeVC.tagModel = tagModel;
|
||||
|
||||
|
||||
// }
|
||||
|
||||
PIHomeCategoryTitleModel *tagModel = [self.tagModelList safeObjectAtIndex1:self.type];
|
||||
XPHomePartyViewController *homeVC = [self.validListDict objectForKey:[NSNumber numberWithInteger:self.type]];
|
||||
homeVC.tagModel = tagModel;
|
||||
}
|
||||
|
||||
-(void)openRoomNotification:(NSNotification *)notification{
|
||||
@@ -260,7 +231,6 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
}
|
||||
}
|
||||
- (void)initSubViewConstraints {
|
||||
|
||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.top.mas_equalTo(self.view);
|
||||
make.height.mas_equalTo(170 + kSafeAreaTopHeight);
|
||||
@@ -270,25 +240,18 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
make.leading.trailing.top.mas_equalTo(self.view);
|
||||
make.height.mas_equalTo(kNavigationHeight);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
[self.pagingView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.navView.mas_bottom).mas_offset(kGetScaleWidth(10));
|
||||
make.leading.bottom.trailing.mas_equalTo(0);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)initHttp {
|
||||
|
||||
[self.presenter getHomeTopData];
|
||||
|
||||
[self requestCheckIp];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - XPNewHomeNavViewDelegate
|
||||
- (void)xPNewHomeNavView:(XPNewHomeNavView *)view didClickRank:(UIButton *)sender {
|
||||
XPWebViewController * webVC =[[XPWebViewController alloc] init];
|
||||
@@ -299,13 +262,12 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
- (void)xPNewHomeNavView:(XPNewHomeNavView *)view didClickOpenRoom:(UIButton *)sender {
|
||||
NSString* roomUid = [AccountInfoStorage instance].getUid;
|
||||
[self opRoom:roomUid];
|
||||
|
||||
}
|
||||
|
||||
-(void)opRoom:(NSString *)roomUid{
|
||||
|
||||
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if(code == 401){
|
||||
|
||||
[self tokenInvalid];
|
||||
[self showErrorToast:msg];
|
||||
return;
|
||||
@@ -325,8 +287,6 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
[self showErrorToast:msg];
|
||||
}
|
||||
} uid:roomUid intoUid:roomUid];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)xPNewHomeNavView:(XPNewHomeNavView *)view didClickSearch:(UIView *)sender {
|
||||
@@ -367,23 +327,14 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
}
|
||||
|
||||
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
||||
|
||||
|
||||
|
||||
// if (index == self.tagModelList.count - 1) {
|
||||
// self.recommendVC.tagModel = [self.tagModelList safeObjectAtIndex1:index];
|
||||
// return self.recommendVC;
|
||||
// } else {
|
||||
id homeV = [self.validListDict objectForKey:[NSNumber numberWithInteger:index]];
|
||||
if (homeV) {
|
||||
return homeV;
|
||||
}
|
||||
XPHomePartyViewController *homeVC = [[XPHomePartyViewController alloc] init];
|
||||
homeVC.tagModel = [self.tagModelList safeObjectAtIndex1:index];
|
||||
[self.validListDict setObject:homeVC forKey:@(index)];
|
||||
return homeVC;
|
||||
// }
|
||||
|
||||
id homeV = [self.validListDict objectForKey:[NSNumber numberWithInteger:index]];
|
||||
if (homeV) {
|
||||
return homeV;
|
||||
}
|
||||
XPHomePartyViewController *homeVC = [[XPHomePartyViewController alloc] init];
|
||||
homeVC.tagModel = [self.tagModelList safeObjectAtIndex1:index];
|
||||
[self.validListDict setObject:homeVC forKey:@(index)];
|
||||
return homeVC;
|
||||
}
|
||||
|
||||
#pragma mark - JXCategoryListContentViewDelegate
|
||||
@@ -408,8 +359,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
if(otherGestureRecognizer.view.tag == 98777){
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
|
||||
}
|
||||
#pragma mark - XPHomeContainerProtocol
|
||||
@@ -426,7 +376,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
NSMutableArray *list = [NSMutableArray new];
|
||||
NSMutableArray *titleArray = [NSMutableArray array];
|
||||
for (PIHomeCategoryTitleModel *model in array) {
|
||||
if (model.isHomeRecommen == YES){
|
||||
if (model.isHomeRecommend == YES){
|
||||
[list insertObject:model atIndex:0];
|
||||
[titleArray insertObject:model.name atIndex:0];
|
||||
}else{
|
||||
@@ -453,10 +403,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
}
|
||||
|
||||
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
|
||||
|
||||
|
||||
self.type = index;
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - XPNewHomeHeadViewDelegate
|
||||
|
Reference in New Issue
Block a user