|
//
// liveTitleCell.m
// ThePaperHD
//
// Created by scar1900 on 15/3/10.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "liveTitleCell.h"
#import "AsyncImageView.h"
#define TABLEWIDTH rect_screen.size.width-60
@interface liveTitleCell()
@property(nonatomic, strong)AsyncImageView *liveImageView;
@property(nonatomic, strong)UILabel *liveLabel;
@property(nonatomic, strong)UIImageView *liveIconView;
@property(nonatomic, strong)UILabel *liveIconLabel;
@property(nonatomic, strong)UIView *lineView;
@end
@implementation liveTitleCell
@synthesize liveInfo = _liveInfo;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self addSubview:self.liveImageView];
[self addSubview:self.liveLabel];
[self addSubview:self.liveIconView];
[self addSubview:self.liveIconLabel];
[self addSubview:self.lineView];
self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
return self;
}
- (void)needrefreshNightMode:(id)sender{
self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
_liveIconLabel.textColor = [UIColor colorWithHexString:TextBlack];
_liveLabel.textColor = [UIColor colorWithHexString:TextBlack];
_lineView.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)setLiveInfo:(liveInfoBO *)data {
_liveInfo = data;
NSAttributedString *attributedString = getLineSpaceAttributedString(data.name,
[iphoneLineSpaceAndParaSpace returnLevel4LineSpace],
appFont(TEXT_THREE_LEVELSIZE, NO));
self.liveLabel.attributedText = attributedString;
self.liveImageView.imageUrl = data.pic;
self.liveImageView.imageId = getImageNameFromURL(data.pic);
int readmode = [[TPUserDefault instance].readModeStr intValue];
if (readmode == intelligentMode) {
if ([Remote IsEnableWIFI]) {
readmode = imageMode;
}else {
readmode = textMode;
}
}
if (readmode == imageMode) {
}else{
self.liveImageView.hidden = YES;
}
[self layoutSubViews];
}
- (UIImageView*)liveIconView {
if (!_liveIconView) {
_liveIconView = [[UIImageView alloc]initWithFrame:CGRectZero];
_liveIconView.image = Image(@"live/liveIcon.png");
}
return _liveIconView;
}
- (UILabel*)liveIconLabel {
if (!_liveIconLabel) {
_liveIconLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_liveIconLabel.font = appFont(TEXT_FOUR_LEVELSIZE, NO);
_liveIconLabel.textColor = [UIColor colorWithHexString:TextBlack];
_liveIconLabel.text = @"直播中";
_liveIconLabel.backgroundColor = [UIColor clearColor];
}
return _liveIconLabel;
}
- (AsyncImageView*)liveImageView {
if (!_liveImageView) {
_liveImageView = [[AsyncImageView alloc]initWithFrame:CGRectZero];
_liveImageView.isHaveWaterPrint = NO;
_liveImageView.backgroundColor = [UIColor clearColor];
_liveImageView.imageView.backgroundColor = [UIColor clearColor];
/**
* bug:5287(打底图问题汇总)
*/
}
return _liveImageView;
}
- (UILabel*)liveLabel {
if (!_liveLabel) {
_liveLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_liveLabel.textAlignment = NSTextAlignmentLeft;
_liveLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO);
_liveLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_liveLabel.textColor = [UIColor colorWithHexString:TextBlack];
_liveLabel.backgroundColor = [UIColor clearColor];
}
return _liveLabel;
}
- (UIView *)lineView {
if (_lineView == nil) {
_lineView = [[UIView alloc] initWithFrame:CGRectZero];
_lineView.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
}
return _lineView;
}
- (void)layoutSubViews {
[self.liveImageView makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.left).offset(10);
make.top.mas_equalTo(self.top).offset(25);
make.width.mas_equalTo(40);
make.height.mas_equalTo(40);
}];
int readmode = [[TPUserDefault instance].readModeStr intValue];
if (readmode == intelligentMode) {
if ([Remote IsEnableWIFI]) {
readmode = imageMode;
}else {
readmode = textMode;
}
}
if (readmode == imageMode) {
[self.liveLabel remakeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.left).offset(65);
make.top.mas_equalTo(self.top).offset(35);
make.width.mas_equalTo(TABLEWIDTH);
make.height.mas_equalTo(18);
}];
}else{
[self.liveLabel remakeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.left).offset(10);
make.top.mas_equalTo(self.top).offset(35);
make.width.mas_equalTo(TABLEWIDTH);
make.height.mas_equalTo(18);
}];
}
[self.liveIconLabel remakeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.right).offset(-5);
make.bottom.mas_equalTo(self.bottom).offset(-5);
make.width.mas_equalTo(56);
make.height.mas_equalTo(15);
}];
[self.liveIconView remakeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.liveIconLabel.left).offset(-5);
make.top.mas_equalTo(self.liveIconLabel.top);
make.width.mas_equalTo(19/2);
make.height.mas_equalTo(30/2);
}];
[self.lineView makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self);
make.right.equalTo(self);
make.bottom.equalTo(self);
make.height.mas_equalTo(1);
}];
// self.lineView.frame = CGRectMake(padding, CGRectGetHeight(self.bounds)-1, TABLEWIDTH, 1);
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
|