澎湃iPad上线版本

hotAskListHomeController.m 12KB

    // // hotAskListHomeController.m // ThePaperHD // // Created by scar1900 on 15/3/4. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "hotAskListHomeController.h" #import "MLNavigationController.h" #import "hotAskListController.h" #import "loginPopUpController.h" #import "otherPersonHomepageController.h" #import "topicContentController.h" @interface hotAskListHomeController ()<hotAskListDelegate,writeContentDelegate> @property(nonatomic, strong)UIButton *closeBtn; @property(nonatomic, strong)MLNavigationController *homeVC; @property(nonatomic, strong)hotAskListController *hotAskVC; @end @implementation hotAskListHomeController @synthesize commentBO; @synthesize homeVC; @synthesize delegate; @synthesize hotAskVC; @synthesize writeVC; @synthesize commentOT; @synthesize isPush; @synthesize isNeedHold; @synthesize closeOrBack; - (id)init { self = [super init]; if (self) { self.isPush = NO; self.closeOrBack = YES; } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self.view addSubview:self.closeBtn]; self.view.backgroundColor = [UIColor clearColor]; self.hotAskVC = [[hotAskListController alloc]init]; hotAskVC.delegate = self; hotAskVC.commentBO = self.commentBO; [self addChildViewController:self.hotAskVC]; self.homeVC = [[MLNavigationController alloc]initWithRootViewController:self.hotAskVC]; self.homeVC.view.backgroundColor = [UIColor clearColor]; self.homeVC.view.frame = CGRectMake(0, 80, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds)-80); [self.view addSubview:self.homeVC.view]; [self addChildViewController:self.homeVC]; // if([self.commentBO.objectType integerValue] ==3) // { // NSDictionary *dic = @{@"topicId":self.commentBO.contId}; // [Remote doJsonAction:1 requestUrl:topicInfoURL parameter:dic // delegate:self]; // } } -(void)viewDidAppear:(BOOL)animated{ isNeedHold = NO; self.closeBtn.hidden = NO; } -(void)viewWillAppear:(BOOL)animated{ isNeedHold = NO; self.closeBtn.hidden = NO; // if([self.commentBO.objectType integerValue] ==3) // { // NSDictionary *dic = @{@"topicId":self.commentBO.contId}; // [Remote doJsonAction:1 requestUrl:topicInfoURL parameter:dic // delegate:self]; // } } - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; self.homeVC.view.frame = CGRectMake(0, 80, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds)-80); self.closeBtn.frame = CGRectMake(0, 0, 50, 80); [self.closeBtn setImageEdgeInsets:UIEdgeInsetsMake(15, 0, 15, 0)]; if (!self.isPush) { [self enablePopBackTap]; }else { [self disablePopBackTap]; } } - (UIButton*)closeBtn { if (!_closeBtn) { _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom]; if (self.closeOrBack) { [_closeBtn setImage:Image(@"login/popUpCloseBtn.png") forState:UIControlStateNormal]; [_closeBtn setImage:Image(@"login/popUpCloseBtn_s.png") forState:UIControlStateHighlighted]; }else{ [_closeBtn setImage:Image(@"login/popUpBack.png") forState:UIControlStateNormal]; [_closeBtn setImage:Image(@"login/popUpBack_h.png") forState:UIControlStateHighlighted]; } [_closeBtn addTarget:self action:@selector(clickClose) forControlEvents:UIControlEventTouchUpInside]; } return _closeBtn; } - (void)goToOriginContent:(objInfoBO *)infoBO presentedController:(TPHttpController *)presentedController {//【需求】问答详情页(bug:3921) if (infoBO) { if ([self.delegate respondsToSelector:@selector(goToOriginContent:presentedController:)]) { self.isNeedHold = YES; [self.delegate goToOriginContent:infoBO presentedController:self]; } } } -(void)hotAskToTopicInfo:(TopicInfoBO *)topic user:(userBO *)user{//【需求】问答详情页(bug:3921) if ([self.delegate respondsToSelector:@selector(hotAskHomeToTopic:user:)]) { self.isNeedHold = YES; // [self.delegate hotAskHomeToTopic:topic user:user]; //我的消息:对一个话题自问自答,在话题的问答详情页点击进入原话题,提示此话题已下线(bug:5813) [self.delegate hotAskHomeToTopic:topic user:nil]; } } - (void)goWriteComment { self.closeBtn.hidden = YES; if (![TPUserDefault instance].userBO) { __weak typeof(self) Self = self; [self pushToLoginVC:^{ [Self dismissPushController]; if ([TPUserDefault instance].userBO) { [Self pushToWriteVC]; } }]; }else { [self pushToWriteVC]; } } - (void)answerBackUser:(commentObjectVO *)commentBackBO closeHidden:(BOOL)ishidden { if (![TPUserDefault instance].userBO) { __weak typeof(self) Self = self; [self pushToLoginVC:^{ [Self dismissPushController]; if ([TPUserDefault instance].userBO) { [Self pushToWriteVC]; } }]; }else { [self pushToWriteVCForUser:commentBackBO]; } if (ishidden) { self.closeBtn.hidden = ishidden; } } - (void)pushToLoginVC:(void (^)())popback{ self.view.frame = CGRectMake(hotAskListPopUpSize.width/2-loginPopUpSize.width/2, hotAskListPopUpSize.height/2-loginPopUpSize.height/2-80, loginPopUpSize.width, loginPopUpSize.height+80); loginPopUpController *loginVC = [[loginPopUpController alloc]init]; loginVC.isPush = YES; loginVC.popBackHandler = popback; [self.homeVC pushViewControllerWithAnimateFlip:loginVC]; } - (void)pushToWriteVC { self.writeVC = [[writeCommentAndAskController alloc]init]; self.view.frame = CGRectMake(hotAskListPopUpSize.width/2-writeAndAskPopSize.width/2, hotAskListPopUpSize.height/2-writeAndAskPopSize.height/2-80, writeAndAskPopSize.width, writeAndAskPopSize.height+80); self.writeVC.type = aswerType; self.writeVC.nodeId = self.commentBO.contId; self.writeVC.delegate = self; self.writeVC.commentBO = self.commentBO; self.writeVC.isPush = YES; if ([self.commentBO.objectType isEqualToString:@"3"]) {//0004269: 个人主页: 通过头像进入个人主页,对列表中的评论、话题的提问进行回复时提示不存在或下线的提示信息(bug:4269) self.writeVC.commentOT = @"3"; }else{ self.writeVC.commentOT = self.commentOT; } [self.homeVC pushViewControllerWithAnimateFlip:self.writeVC]; } - (void)pushToWriteVCForUser:(commentObjectVO*)commentBackBO { self.writeVC = [[writeCommentAndAskController alloc]init]; self.view.frame = CGRectMake(hotAskListPopUpSize.width/2-writeAndAskPopSize.width/2, hotAskListPopUpSize.height/2-writeAndAskPopSize.height/2-80, writeAndAskPopSize.width, writeAndAskPopSize.height+80); self.writeVC.type = askForUserType; self.writeVC.nodeId = self.commentBO.contId; self.writeVC.delegate = self; self.writeVC.commentBO = commentBackBO; self.writeVC.isPush = YES; if([self.commentBO.objectType isEqualToString:@"3"]){//0004269: 个人主页: 通过头像进入个人主页,对列表中的评论、话题的提问进行回复时提示不存在或下线的提示信息(bug:4269) self.writeVC.commentOT = @"3"; }else{ self.writeVC.commentOT = self.commentOT; } [self.homeVC pushViewControllerWithAnimateFlip:self.writeVC]; } -(void)gotoParent:(commentObjectVO *)comment{ isNeedHold = YES; if ([self.delegate respondsToSelector:@selector(gotoPersonInfo:)]) { [self.delegate gotoPersonInfo:comment]; } // [self dismissControllerAnimated:YES completion:^{ // otherPersonHomepageController *otherVC = [otherPersonHomepageController new]; // otherVC.commentBo = commentBO; // [self.navigationController pushViewController:otherVC animated:YES]; // }]; } - (void)writeConetentPopBack { [self dismissPushController]; [self enablePopBackTap]; } - (void)dismissPushController { self.view.frame = CGRectMake(0, 0, hotAskListPopUpSize.width, hotAskListPopUpSize.height); [self.homeVC popViewControllerWithFlip]; self.writeVC = nil; self.closeBtn.hidden = NO; } - (void)clickClose { if (!isPush) { [self dismissControllerAnimated:YES completion:nil]; }else { [(MLNavigationController*)self.navigationController popViewControllerWithFlip]; } if (closeOrBack) { [self dismissControllerAnimated:YES completion:nil]; }else { [(MLNavigationController*)self.navigationController popViewControllerWithFlip]; } } - (void)commentSuccess:(commentAndAskType)type { [self dismissPushController]; [self.hotAskVC manualRefresh]; } - (void)focusCurrentAsk:(commentObjectVO *)comment isToFocus:(BOOL)isToFocus button:(UIButton *)btn { NSDictionary *dic = @{@"commentId":comment.commentId}; if (isToFocus) { if ([TPUserDefault instance].userBO) { [Remote doJsonActionWithBlock:1 requestUrl:addAttentionURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) { if (success) { [MobClick event:@"25"]; ShowMessage(@"关注成功", YES); btn.selected = isToFocus; commentObjectVO* commentData = self.hotAskVC.qaDataSource[0]; commentData.isAttented = @"1"; }else { ShowTextMessage(message); } }]; }else { __weak typeof(self) Self = self; [self pushToLoginVC:^{ [Self dismissPushController]; if (![TPUserDefault instance].userBO) { return; } [Remote doJsonActionWithBlock:1 requestUrl:addAttentionURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) { if (success) { ShowMessage(@"关注成功", YES); btn.selected = isToFocus; commentObjectVO* commentData = Self.hotAskVC.qaDataSource[0]; commentData.isAttented = @"1"; }else { ShowTextMessage(message); } }]; }]; } }else { __weak typeof(self) Self = self; [Remote doJsonActionWithBlock:1 requestUrl:cancelAttentionURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) { if (success) { ShowMessage(@"取消关注", YES); btn.selected = isToFocus; commentObjectVO* commentData = Self.hotAskVC.qaDataSource[0]; commentData.isAttented = @"0"; }else { ShowTextMessage(message); } }]; } } -(void)remoteResponsSuccess:(int)actionTag withResponsData:(id)responsData{ TopicInfoBO *topic = setJsonDicToDataModel(responsData[@"topicInfo"], [TopicInfoBO class]); userBO *user = setJsonDicToDataModel(topic.userInfo, [userBO class]); self.hotAskVC.topicHostId =user.userId; } - (void)remoteResponsFailed:(int)actionTag withMessage:(NSString *)message resultCode:(NSString *)code { if ([code intValue] != 5) { ShowTextMessage(message); } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end