|
//
// myFocusController.m
// ThePaperHD
//
// Created by scar1900 on 15/3/30.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "myFocusController.h"
@interface myFocusController ()<askContentCellDelgate,hotAskListHomeDelegate> {
UIView *_noDataBack;
}
@end
@implementation myFocusController
@synthesize delegate;
@synthesize qaList = _qaList;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (UIView*)noDataBack {
if (!_noDataBack) {
_noDataBack = [[UIView alloc]initWithFrame:CGRectMake(0,
0,
myAskCenterPopSize.width,
CGRectGetHeight(self.view.bounds))];
_noDataBack.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_noDataBack.hidden = YES;
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(80, 218/2, 820/2, 96/2)];
label.textColor = [UIColor colorWithHexString:TextGray];
label.font = appFont(20, NO);
label.textAlignment = NSTextAlignmentLeft;
label.lineBreakMode = NSLineBreakByWordWrapping;
label.numberOfLines = 0;
label.backgroundColor = [UIColor clearColor];
label.text = @"看问题时点击(关注)按钮,关注一个问题,这里将集纳对该问题的新旧回答。";
[_noDataBack addSubview:label];
UIImageView *imageView = [[UIImageView alloc]initWithImage:Image(@"other/focusNoDataBack.png")];
imageView.frame = CGRectMake(myAskCenterPopSize.width/2-486/4, CGRectGetMaxY(label.frame)+35/2, 486/2, 590/2);
[_noDataBack addSubview:imageView];
}
return _noDataBack;
}
- (void)setQaList:(NSMutableArray *)list {
_qaList = list;
if ([self checkIfNoData:list]) {
return;
}
self.qaDataSource = [NSMutableArray array];
self.qaHeightArray = [NSMutableArray array];
[self.qaList enumerateObjectsUsingBlock:^(commentObjectVO* obj, NSUInteger idx, BOOL *stop) {
if ([obj.type intValue] == 2) {
[self.qaDataSource addObject:obj];
CGFloat titleHeight = 50+returnTextHeightWithRTLabel(obj.content,930/2, appFont(15, NO),10)+15; //(姓名+内容高度+空行)
[self.qaHeightArray addObject:[NSString stringWithFormat:@"%f",titleHeight]];
}
}];
[self.tableView reloadData];
if ([self.delegate respondsToSelector:@selector(remoteSuccess)]) {
[self.delegate remoteSuccess];
}
}
- (void)pullRefreshHandler {
[Remote doJsonAction:1
requestUrl:myAttentionListURL
parameter:nil
delegate:self];
}
//问题内容
- (hotAskContentCell*)getAskContentCell:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"askContentCell";
hotAskContentCell *cell = (hotAskContentCell*)[tableView dequeueReusableCellWithIdentifier:cellID];
if (nil == cell) {
cell = [[hotAskContentCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
cell.dashedLineView.hidden = YES;
UIView *line = [[UIView alloc]init];
line.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
line.tag = 20;
[cell addSubview:line];
}
cell.commentBO = self.qaDataSource[indexPath.row];
cell.isHaveMenu = NO;
cell.askContentDelegate =self;
UIView *line = [cell viewWithTag:20];
CGFloat height = [self.qaHeightArray[indexPath.row] floatValue];
line.frame = CGRectMake(15,height-1, myAskCenterPopSize.width-30, 1);
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
commentObjectVO *comment = self.qaDataSource[indexPath.row];
NSDictionary *dic = @{@"commentId":comment.commentId};
__weak typeof(self) Self = self;
[Remote doJsonActionWithBlock:0 requestUrl:cancelAttentionURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) {
if (success) {
[Self.qaDataSource removeObjectAtIndex:indexPath.row];
[Self.qaHeightArray removeObjectAtIndex:indexPath.row];
// Delete the row from the data source.
[Self.tableView beginUpdates];
[Self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
if (self.qaDataSource.count ==0) {
if ([self.delegate respondsToSelector:@selector(deleteAllFocus)]) {
[self.delegate deleteAllFocus];
}
}
[self checkIfNoData:self.qaDataSource];
[Self.tableView endUpdates];
}else {
ShowMessage(message, NO);
}
}];
}
}
-(void)gotoUserInfo:(commentObjectVO *)comment{
if ([self.delegate respondsToSelector:@selector(gotoUserGambit:)]) {
[self.delegate gotoUserGambit:comment];
}
}
-(void)gotoPersonInfo:(commentObjectVO *)comment{
if ([self.delegate respondsToSelector:@selector(gotoUserGambit:)]) {
[self.delegate gotoUserGambit:comment];
}
}
-(void)hotAskHomeToTopic:(TopicInfoBO *)topic user:(userBO *)user{
if ([self.delegate respondsToSelector:@selector(foucsToAskCenterTopic:user:)]) {
[self.delegate foucsToAskCenterTopic:topic user:user];
}
}
- (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
|