澎湃iPad上线版本

liveViewModel.m 31KB

    // // liveViewModel.m // ThePaperHD // // Created by scar1900 on 15/7/2. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "liveViewModel.h" #define getLiveInfoTag 100 #define getCommentInfoTag 101 #define getAskInfoTag 102 #define loadMoreTag 103 #define liveTitleHeight isPad?@"100":@"90" #define topDateHeight isPad?@"45":@"35" #define topTitlePadding isPad?@"36":@"24" #define topTitleFont 18.f #define lineSpace isPad?@"8":@"10" #define contentPadding isPad?@"30":@"10" #define videoDescFont 15.f #define videoSizeHight isPad?@"300":@"150" #define videoPadding isPad?@"10":@"7" #define videoBottomPadding isPad?@"40":@"20" #define cellHeightScale isPad?@"1.1":@"1" #define imageLineSpace isPad?@"8":@"5" #define paragraphSpace isPad?@"30":@"20" #define imageDescWidth isPad?(float)1060/2:(float)(rect_screen.size.width-60) @interface liveViewModel() <RemoteDelegate,ALMoviePlayerControllerDelegate> { CGFloat contentWidth; UIView *videoSuperView; } @property(nonatomic, strong)liveDetailPageVO *livePageBO; @property(nonatomic, strong)liveInfoBO *liveInfoBO; @property(nonatomic, strong)ALMoviePlayerController *moviePlayerController; @end @implementation liveViewModel @synthesize delegate; @synthesize livePageBO = _livePageBO; @synthesize liveInfoBO = _liveInfoBO; -(instancetype)init { self = [super init]; if (self) { if (isPad) { contentWidth = 1060/2; }else { contentWidth = rect_screen.size.width-50-10; } } return self; } #pragma mark - set and get method - (void)setLivePageBO:(liveDetailPageVO *)pageBO { _livePageBO = pageBO; if([self.delegate respondsToSelector:@selector(getLiveDetailPageData:)]) { [self.delegate getLiveDetailPageData:pageBO]; } } - (void)setLiveInfoBO:(liveInfoBO *)infoBO { _liveInfoBO = infoBO; if ([self.delegate respondsToSelector:@selector(getLiveInfo:)]) { [self.delegate getLiveInfo:infoBO]; } } #pragma mark - public method && private method - (void)remoteAction { NSDictionary *dic = @{@"c":self.nodeId}; [Remote doJsonAction:getLiveInfoTag requestUrl:liveDetailPageURL parameter:dic delegate:self]; NSDictionary *dic1 = @{@"ot":@"2",@"c":self.nodeId}; /** * bug:5084(直播的追问互动列表不显示互动数) */ [Remote doJsonAction:getCommentInfoTag requestUrl:contentCommentURL parameter:dic1 delegate:self]; [Remote doJsonAction:getAskInfoTag requestUrl:contentAskURL parameter:dic1 delegate:self]; } - (void)remotePullMethod { NSDictionary *dic = @{@"n":self.nodeId}; [Remote doJsonAction:getLiveInfoTag requestUrl:liveDetailPageURL parameter:dic delegate:self]; } - (void)remotePullLoadMethod:(NSString*)nextUrl{ [Remote doJsonAction:loadMoreTag requestUrl:nextUrl parameter:nil delegate:self]; } - (void)getTableDataSourceWithLivePageData:(liveDetailPageVO*)pageBO completion:(void (^)(NSMutableArray* dataSource, NSMutableArray *sectionTitleList, NSMutableArray *heightList, NSString *nextUrl))completion{ self.liveInfoBO = setJsonDicToDataModel(pageBO.liveInfo, [liveInfoBO class]); NSMutableArray *tempDataList = [NSMutableArray array]; NSMutableArray *heightList = [NSMutableArray array]; NSMutableArray *sectionTitleList = [NSMutableArray array]; //直播标题和banner [tempDataList addObject:self.liveInfoBO]; [heightList addObject:liveTitleHeight]; [sectionTitleList addObject:@""]; NSMutableArray *topList = [NSMutableArray arrayWithArray:pageBO.topList]; if (topList && topList.count > 0) { NSMutableArray *topContentList = [NSMutableArray array]; NSMutableArray *topSectionHeightList = [NSMutableArray array]; [sectionTitleList addObject:@""]; [topList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { liveContBO *liveCont = setJsonDicToDataModel(obj, [liveContBO class]); NSString *date = [liveCont.pubTime stringByAppendingString:[NSString stringWithFormat:@" %@",liveCont.pubDate]]; NSDictionary *topDate = @{@"type":@"topDate",@"date":date}; [topContentList addObject:topDate]; [topSectionHeightList addObject:topDateHeight]; NSString *contTitle = liveCont.name; NSDictionary *titleDic = @{@"title":contTitle,@"type":@"topTitle"}; [topContentList addObject:titleDic]; // CGFloat titleHeight = returnTextHeightWithRTLabel(contTitle, // contentWidth, // appFont(topTitleFont, NO), // [lineSpace floatValue])+[topTitlePadding floatValue]; CGFloat titleHeight = heightForString(contTitle, appFont(liveTitleFonteSize, NO), contentWidth, NSLineBreakByWordWrapping)+20+authorAndTimeToTextAndImgAndVedio; [topSectionHeightList addObject:[NSString stringWithFormat:@"%f",titleHeight]]; [self addContentToDataList:topContentList heightArray:topSectionHeightList liveCont:liveCont isTop:YES]; }]; [tempDataList addObject:topContentList]; [heightList addObject:topSectionHeightList]; } NSMutableArray *contentDataList = [NSMutableArray arrayWithArray:pageBO.dateList]; if (contentDataList && contentDataList.count>0) { [contentDataList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSString *date = obj[@"pubDate"]; NSString *currStr = StringFromDate([NSDate date], @"YYYY-MM-dd"); // NSString *currStr = @"2014-07-22"; if ([currStr isEqualToString:date]) { date = @""; } [sectionTitleList addObject:date]; NSArray *sectionContent = obj[@"contList"]; NSMutableArray *contentSectionHeightList = [NSMutableArray array]; NSMutableArray *contentList = [NSMutableArray array]; [sectionContent enumerateObjectsUsingBlock:^(NSDictionary* liveContDic, NSUInteger index, BOOL *stoped) { liveContBO *liveCont = setJsonDicToDataModel(liveContDic, [liveContBO class]); NSString *contentDate = liveCont.pubTime; NSString *contTitle = liveCont.name; NSDictionary *titleDic = @{@"title":contTitle,@"date":contentDate,@"type":@"contentTitle"}; [contentList addObject:titleDic]; // CGFloat titleHeight = returnTextHeightWithRTLabel(contTitle, contentWidth, appFont(18, NO), 8)+36; CGFloat titleHeight = heightForString(contTitle, appFont(liveTitleFonteSize, NO), contentWidth, NSLineBreakByWordWrapping)+20+authorAndTimeToTextAndImgAndVedio; [contentSectionHeightList addObject:[NSString stringWithFormat:@"%f",titleHeight]]; [self addContentToDataList:contentList heightArray:contentSectionHeightList liveCont:liveCont isTop:NO]; }]; [tempDataList addObject:contentList]; [heightList addObject:contentSectionHeightList]; }]; } if (completion) { completion(tempDataList,sectionTitleList,heightList,pageBO.nextUrl); } } - (void)getMoreFootData:(NSMutableArray *)sourceList responseData:(id)responsData heightList:(NSMutableArray*)heightList titleList:(NSMutableArray*)titleList completion:(void (^)(NSMutableArray* dataSource, NSMutableArray *sectionTitleList, NSMutableArray *heightList, NSString *nextUrl))completion{ NSMutableArray *tempList = [NSMutableArray arrayWithArray:sourceList]; NSArray *array = responsData[@"dateList"]; [array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSString *date = obj[@"pubDate"]; // if(![sectionTitleHeightList[sectionTitleHeightList.count -1] isEqualToString:date]){ // [sectionTitleHeightList addObject:date]; // } NSArray *sectionContent = obj[@"contList"]; NSMutableArray *contentList = [NSMutableArray array]; NSMutableArray *sectionHeightArray = [NSMutableArray array]; NSMutableArray *forwardDataArray = tempList[tempList.count -1]; NSMutableArray *forwardHeightArray = heightList[heightList.count -1]; [sectionContent enumerateObjectsUsingBlock:^(id obj0, NSUInteger idx0, BOOL *stop0) { liveContBO *liveContent = setJsonDicToDataModel(obj0, [liveContBO class]); NSString *contentDate = liveContent.pubTime; NSString *contTitle = liveContent.name; NSDictionary *titleDic = @{@"title":contTitle,@"date":contentDate,@"type":@"contentTitle"}; // CGFloat titleHeight = returnTextHeightWithRTLabel(contTitle, // contentWidth, // appFont(liveTitleFonteSize, NO), // [lineSpace floatValue])+[topTitlePadding floatValue];; CGFloat titleHeight = heightForString(contTitle, appFont(liveTitleFonteSize, NO), contentWidth, NSLineBreakByWordWrapping)+20+authorAndTimeToTextAndImgAndVedio; if ([liveContent.pubDate isEqualToString:titleList[titleList.count-1]]) { [forwardHeightArray addObject:[NSString stringWithFormat:@"%f",titleHeight]]; [forwardDataArray addObject:titleDic]; [self addContentToDataList:forwardDataArray heightArray:forwardHeightArray liveCont:liveContent isTop:NO]; }else{ [sectionHeightArray addObject:[NSString stringWithFormat:@"%f",titleHeight]]; [contentList addObject:titleDic]; [self addContentToDataList:contentList heightArray:sectionHeightArray liveCont:liveContent isTop:NO]; } }]; if([titleList[titleList.count -1] isEqualToString:date]){ [tempList replaceObjectAtIndex:tempList.count-1 withObject:forwardDataArray]; [heightList replaceObjectAtIndex:heightList.count-1 withObject:forwardHeightArray]; }else{ [titleList addObject:date]; [tempList addObject:contentList]; [heightList addObject:sectionHeightArray]; } }]; if (tempList && tempList.count >0) { sourceList = [NSMutableArray arrayWithArray:tempList]; } if (completion) { completion(sourceList,titleList,heightList,responsData[@"nextUrl"]); } } - (void)adVideoInView:(UIView*)view videoFrame:(CGRect)videoFrame videoData:(videoObjectBO*)videoBO { if (self.moviePlayerController) { return; } [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide]; self.moviePlayerController = nil; self.moviePlayerController = [[ALMoviePlayerController alloc] initWithFrame:view.bounds]; self.moviePlayerController.view.backgroundColor = [UIColor blackColor]; ALMoviePlayerControls *movieControls = [[ALMoviePlayerControls alloc] initWithMoviePlayer:self.moviePlayerController style:ALMoviePlayerControlsStyleEmbedded]; [movieControls setBarHeight:40.f]; self.moviePlayerController.movieFullscreen = YES; self.moviePlayerController.delegate = self; self.moviePlayerController.controls = movieControls; [view addSubview:self.moviePlayerController.view]; videoSuperView = view; [self.moviePlayerController setContentURL:[NSURL URLWithString:videoBO.url]]; [self.moviePlayerController setFullscreen:YES]; [self.moviePlayerController shouldAutoplay]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; [UIView animateWithDuration:0.3 animations:^{ [self.moviePlayerController setFrame:view.bounds]; } completion:^(BOOL finished) { }]; } - (void)addContentToDataList:(NSMutableArray *)contentArray heightArray:(NSMutableArray*)heightArray liveCont:(liveContBO*)liveCont isTop:(BOOL)isTop{ NSArray *imageList = liveCont.images; //视频 NSArray *videoList = liveCont.videos; if (videoList.count > 0) { NSMutableDictionary *videoDic = [NSMutableDictionary dictionary]; [imageList enumerateObjectsUsingBlock:^(NSDictionary* obj1, NSUInteger idx1, BOOL *stop1) { imageObjectBO *imgBO = setJsonDicToDataModel(obj1, [imageObjectBO class]); if ([imgBO.tags isEqualToString:@"www_video"] || [imgBO.tags isEqualToString:@"www_big"]) { [videoDic setValue:imgBO forKey:@"image"]; NSString *type = @""; if (isTop) { type = @"topvideo"; }else type = @"video"; [videoDic setValue:type forKey:@"type"]; *stop1 = YES; } }]; [videoList enumerateObjectsUsingBlock:^(id obj2, NSUInteger idx2, BOOL *stop2) { videoObjectBO *video = setJsonDicToDataModel(obj2, [videoObjectBO class]); CGFloat videoHeight = [videoSizeHight floatValue]+[videoPadding floatValue]; videoHeight = videoHeight + [self returnContentExtendHeight:video.name]; [videoDic setValue:video forKey:@"video"]; int readmode = [[TPUserDefault instance].readModeStr intValue]; if (readmode == intelligentMode) { if ([Remote IsEnableWIFI]) { readmode = imageMode; }else { readmode = textMode; } } if (readmode == imageMode) { }else{ if (![video.isTap isEqualToString:@"1"]) { videoHeight = 130 + [self returnContentExtendHeight:video.name]; } } [heightArray addObject:[NSString stringWithFormat:@"%f",videoHeight]]; }]; [contentArray addObject:videoDic]; } NSArray *textAndContentList = liveCont.content; //文章详情 // NSMutableArray *analysisedContentList = [self analysisContent:textAndContentList]; //【倒退】iPad新闻详情页:有几篇新闻显示异常(bug:5649) NSMutableArray *analysisedContentList = analysisContent(textAndContentList); [analysisedContentList enumerateObjectsUsingBlock:^(id obj3, NSUInteger idx3, BOOL *stop3) { if ([obj3 isKindOfClass:[imageObjectBO class]]) { imageObjectBO *imageBO = obj3; if ([imageBO.url isMatchedByRegex:@"224"]) { imageBO.url = [imageBO.url stringByReplacingOccurrencesOfString:@"224" withString:@"247"]; } CGFloat cellHeight = 0; if ([imageBO.width floatValue] > contentWidth) { cellHeight = [imageBO.height floatValue]*contentWidth/[imageBO.width floatValue]; }else if([imageBO.width floatValue] >=480 && [imageBO.width floatValue] <=contentWidth){ cellHeight = [imageBO.height floatValue]; }else{ cellHeight = [imageBO.height floatValue]*[cellHeightScale floatValue]; } CGFloat imageExHeight = [self returnContentExtendHeight:imageBO.desc]; cellHeight = cellHeight+imageExHeight; int readmode = [[TPUserDefault instance].readModeStr intValue]; if (readmode == intelligentMode) { if ([Remote IsEnableWIFI]) { readmode = imageMode; }else { readmode = textMode; } } if (readmode == imageMode) { }else{ cellHeight = 120+imageExHeight+10; } [heightArray addObject:[NSString stringWithFormat:@"%f",cellHeight]]; NSString *type = @""; if (isTop) { type = @"topimage"; }else type = @"image"; NSDictionary *imageDic = @{@"type":type,@"imageBO":imageBO,@"imageList":liveCont.textImages}; [contentArray addObject:imageDic]; }else { NSString *str = obj3; UIFont *font = appFont([TPUserDefault instance].contFontSize, NO); NSArray *colorList = [str componentsMatchedByRegex:@"\\<[C]\\:[0-9A-Za-z]{6}>"]; __block NSString *oriStr = str; [colorList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSString* hexStr = [obj stringByMatching:@"[0-9A-Za-z]{6}"]; NSString *replacedStr = [NSString stringWithFormat:@"<color value=\"#%@\">",hexStr]; oriStr = [oriStr stringByReplacingOccurrencesOfRegex:obj withString:replacedStr]; }]; str = oriStr; str = [str stringByReplacingOccurrencesOfString:@"<N>" withString:@"</>"]; // if (![str isMatchedByRegex:@"/font"]) {//修复bug:4487 // str = [str stringByAppendingString:@"</font>"]; // } NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; // paragraphStyle.lineSpacing = 6;// 字体的行间距 paragraphStyle.lineSpacing = [ipadLineAndParaSpace liveLineSpace];// 字体的行间距 NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: // font, NSFontAttributeName, paragraphStyle,NSParagraphStyleAttributeName, // [UIColor colorWithHexString:TextBlack],NSForegroundColorAttributeName, nil]; NSAttributedString *tempStr = attributedStringWithHtml(str); NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc]initWithAttributedString:tempStr]; NSRange range = NSMakeRange(0, tempStr.length); [attributeStr addAttributes:attributes range:range]; CGFloat strHeight = heightForAttributeStringWithLabel(attributeStr, contentWidth, font); // CGFloat cellHeight = strHeight+[contentPadding floatValue]; CGFloat cellHeight = strHeight+[ipadLineAndParaSpace liveColumSpace];//(bug:5663) [heightArray addObject:[NSString stringWithFormat:@"%f",cellHeight]]; NSString *type = @""; if (isTop) { type = @"topcontentText"; }else type = @"contentText"; NSDictionary *dic = @{@"type":type,@"text":attributeStr}; [contentArray addObject:dic]; } }]; NSMutableDictionary *shareDic = [NSMutableDictionary dictionary]; NSString *type = @""; if (isTop) { type = @"topshare"; }else type = @"share"; [shareDic setValue:type forKey:@"type"]; [shareDic setValue:liveCont.name forKey:@"title"]; if (liveCont.strongRelateCont) { listContObjectVO *listBO = setJsonDicToDataModel(liveCont.strongRelateCont, [listContObjectVO class]); [shareDic setValue:listBO forKey:@"strongRelate"]; } [contentArray addObject:shareDic]; [heightArray addObject:[NSString stringWithFormat:@"%f",55.f]]; } - (CGFloat)returnContentExtendHeight:(NSString*)str { BOOL isHaveDesc = NO; if (!isBlankString(str)) { isHaveDesc = YES; } if (isHaveDesc) { CGFloat descHeight = returnTextHeightWithRTLabel(str, imageDescWidth, appFont(imageDescFontSize, NO), [ipadLineAndParaSpace liveLineSpace]); return descHeight + [ipadLineAndParaSpace liveColumSpace]+5; }else { return [ipadLineAndParaSpace imgLineSpace]; } } ////解析文章详情内容 //- (NSMutableArray *)analysisContent:(NSArray*)list { // NSMutableArray *analysisedList = [NSMutableArray array]; // [list enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { // sectionContentBO *sectionBO = setJsonDicToDataModel(obj, [sectionContentBO class]); // if (sectionBO) { // if (sectionBO.content && ![sectionBO.content isEqualToString:@""]) { // NSString *contentStr = sectionBO.content; // if ([contentStr isMatchedByRegex:@"\n</U>"]) {//bug:3901 // contentStr = [contentStr stringByReplacingOccurrencesOfString:@"\n</U>" withString:@"</U>\n"]; // } // NSArray *deperateArray = [contentStr componentsSeparatedByRegex:@"\n"]; // __block BOOL isHaveBFlag = NO; // __block BOOL isHaveUFlag = NO; // __block BOOL isHaveCFlag = NO; // __block NSString *colorStr = @""; // [deperateArray enumerateObjectsUsingBlock:^(id item, NSUInteger index, BOOL *stoped) { // // if ([item isEqualToString:@"<B>"]) { // // item = @"<B></B>"; // // }else if ([item isEqualToString:@"</B>"]) { // // item = @"<B></B>"; // // }else { // // if ([item isMatchedByRegex:@"<B>"] && ![item isMatchedByRegex:@"</B>"]) { // // item = [item stringByAppendingString:@"</B>"]; // // }else if (![item isMatchedByRegex:@"<B>"] && [item isMatchedByRegex:@"</B>"]) { // // item = [NSString stringWithFormat:@"<B>%@",item]; // // } // // } // // if (isHaveBFlag) { // item = [NSString stringWithFormat:@"<B>%@",item]; // } // // BOOL isHaveB = [item isMatchedByRegex:@"<B>"]; // BOOL isHaveEndB = [item isMatchedByRegex:@"</B>"]; // if (isHaveB) { // isHaveBFlag = YES; // if (!isHaveEndB) { // item = [item stringByAppendingString:@"</B>"]; // }else { // isHaveBFlag = NO; // } // }else { // isHaveBFlag = NO; // } // // // if (isHaveUFlag) { // item = [NSString stringWithFormat:@"<U>%@",item]; // } // // BOOL isHaveU = [item isMatchedByRegex:@"<U>"]; // BOOL isHaveEndU = [item isMatchedByRegex:@"</U>"]; // if (isHaveU) { // isHaveUFlag = YES; // if (!isHaveEndU) { // item = [item stringByAppendingString:@"</U>"]; // }else { // isHaveUFlag = NO; // } // }else { // isHaveUFlag = NO; // } // // if (isHaveCFlag) { // item = [NSString stringWithFormat:@"%@%@",colorStr,item]; // } // // BOOL isHaveC = [item isMatchedByRegex:@"<C"]; // BOOL isHaveEndC = [item isMatchedByRegex:@"<N>"]; // if (isHaveC) { // isHaveCFlag = YES; // colorStr = [item stringByMatching:@"\\<[C]\\:[0-9A-Za-z]{6}>"]; // if (!isHaveEndC) { // item = [item stringByAppendingString:@"<N>"]; // }else { // isHaveCFlag = NO; // } // }else { // isHaveCFlag = NO; // } // // /** // * bug:(正文渲染问题(5362,5171,5248,5216)) // */ // // [analysisedList addObject:item]; // }]; // } // // if (sectionBO.imageInfoList.count > 0) { // [sectionBO.imageInfoList enumerateObjectsUsingBlock:^(NSDictionary* dic, NSUInteger index, BOOL *stop) { // imageObjectBO *imageBO = setJsonDicToDataModel(dic, [imageObjectBO class]); // if (imageBO) { // [analysisedList addObject:imageBO]; // } // }]; // } // } // }]; // // return analysisedList; //} #pragma mark - remote delegate - (void)startWaitCursor:(int)actionTag { } - (void)stopWaitCursor:(int)actionTag { } - (void)remoteResponsSuccess:(int)actionTag withResponsData:(id)responsData { if (actionTag == getLiveInfoTag) { self.livePageBO = setJsonDicToDataModel(responsData, [liveDetailPageVO class]); self.liveInfoBO = setJsonDicToDataModel(self.livePageBO.liveInfo, [liveInfoBO class]); }else if (actionTag == getCommentInfoTag) { NSMutableArray* commentList = [NSMutableArray array]; NSMutableArray *hotList = [NSMutableArray array]; NSArray *list = responsData[@"commentList"]; NSArray *hotDicList = responsData[@"hotList"]; [list enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) { commentObjectVO *commentBO = setJsonDicToDataModel(obj, [commentObjectVO class]); commentBO = setStrSpaceForParagraphSpacingWithCommentBO(commentBO); [commentList addObject:commentBO]; }]; [hotDicList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { commentObjectVO *commentBO = setJsonDicToDataModel(obj, [commentObjectVO class]); commentBO = setStrSpaceForParagraphSpacingWithCommentBO(commentBO); [hotList addObject:commentBO]; }]; NSMutableArray *commentDataList = [NSMutableArray array]; if (hotList.count > 0) { [commentDataList addObject:hotList]; } [commentDataList addObject:commentList]; if ([self.delegate respondsToSelector:@selector(returnCommentList:nodeId:nextUrl:commentTotalRecord:)]) { NSMutableArray *array = [NSMutableArray array]; array = [NSMutableArray arrayWithArray:commentDataList]; [self.delegate returnCommentList:array nodeId:self.nodeId nextUrl:responsData[@"nextUrl"] commentTotalRecord:[responsData[@"recordTotal"] integerValue]]; } }else if (actionTag == getAskInfoTag) { NSMutableDictionary *qaDataDic = [NSMutableDictionary dictionary]; NSArray *hotQaList = responsData[@"hotQaList"]; NSMutableArray *hotQaArray = [NSMutableArray array]; [hotQaList enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) { commentObjectVO *commentBO = setJsonDicToDataModel(obj, [commentObjectVO class]); commentBO = setStrSpaceForParagraphSpacingWithCommentBO(commentBO); [hotQaArray addObject:commentBO]; }]; [qaDataDic setValue:hotQaArray forKey:@"hotQaList"]; NSArray *qaTempList = responsData[@"qaList"]; NSMutableArray *qaArray = [NSMutableArray array]; [qaTempList enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) { commentObjectVO *commentBO = setJsonDicToDataModel(obj, [commentObjectVO class]); commentBO = setStrSpaceForParagraphSpacingWithCommentBO(commentBO); [qaArray addObject:commentBO]; }]; [qaDataDic setValue:qaArray forKey:@"qaList"]; if ([self.delegate respondsToSelector:@selector(returnHotAskDic:nodeId:nextUrl:askTotalRecord:)]) { [self.delegate returnHotAskDic:qaDataDic nodeId:self.nodeId nextUrl:responsData[@"nextUrl"] askTotalRecord:[responsData[@"qaNum"] integerValue]]; } }else if (actionTag == loadMoreTag) { if ([self.delegate respondsToSelector:@selector(returnMoreInfoData:)]) { [self.delegate returnMoreInfoData:responsData]; } } } - (void)remoteResponsFailed:(int)actionTag withMessage:(NSString *)message resultCode:(NSString *)code { if ([code intValue] == 5) { if ([self.delegate respondsToSelector:@selector(contentHaveOffline)]) { [self.delegate contentHaveOffline]; } }else { ShowTextMessage(message); if ([self.delegate respondsToSelector:@selector(remoteFail)]) { [self.delegate remoteFail]; } } } #pragma mark - video delegate - (void)playFinish:(NSNotification*)notification { [self stopAndRemoveVideo]; } - (void)moviePlayerWillMoveFromWindow { } - (void)dealloc { [[NSNotificationCenter defaultCenter]removeObserver:self]; } - (void)enterFullScreen:(BOOL)isEnter { if (!isEnter) { [self stopAndRemoveVideo]; //视频:直播页和详情页播放视频,全屏播放视频,点击右上角的叉,会点到状态栏,导致底部页面弹回头部(bug:5748) if ([self.delegate respondsToSelector:@selector(hiddenStatusBar:)]) { [self.delegate hiddenStatusBar:isEnter]; } }else{ if ([self.delegate respondsToSelector:@selector(hiddenStatusBar:)]) { [self.delegate hiddenStatusBar:isEnter]; } } } - (void)closeHandler { [self stopAndRemoveVideo]; } - (void)stopAndRemoveVideo { if ([self.moviePlayerController isFullscreen]) { [self.moviePlayerController setFullscreen:NO animated:YES]; } [self.moviePlayerController stop]; [self.moviePlayerController.view removeFromSuperview]; self.moviePlayerController = nil; [CoreAnimationEffect animationEaseOut:videoSuperView]; } @end