|
//
// videoCell.m
// ThePaperDemo
//
// Created by scar1900 on 14/11/5.
// Copyright (c) 2014年 scar1900. All rights reserved.
//
#import "videoCell.h"
#import "AsyncImageView.h"
@interface videoCell() {
}
@property(nonatomic, strong)AsyncImageView *imgView;
@property(nonatomic, strong)UILabel *destLabel;
@property(nonatomic, strong)UIImageView *videoImage;
@end
@implementation videoCell
@synthesize imageBO = _imageBO;
@synthesize videoBO = _videoBO;
@synthesize delegate;
@synthesize indexPath;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.imgView];
[self.contentView addSubview:self.destLabel];
[self.imgView addSubview:self.videoImage];
}
return self;
}
- (UIImageView*)videoImage {
if (!_videoImage) {
_videoImage = [[UIImageView alloc]initWithImage:Image(@"detailPage/videoBack.png")];
}
return _videoImage;
}
- (void)setImageBO:(imageObjectBO *)data {
_imageBO = data;
if ([data.tags isEqualToString:@"www_video"] || [data.tags isEqualToString:@"www_big"]) {
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickVideo:)];
[self.imgView addGestureRecognizer:tapGesture];
self.videoImage.hidden = NO;
}else {
self.videoImage.hidden = YES;
}
self.imgView.imageUrl = data.url;
}
- (void)setVideoBO:(videoObjectBO *)video {
_videoBO = video;
self.destLabel.text = video.name;
}
- (AsyncImageView*)imgView {
if (!_imgView) {
_imgView = [[AsyncImageView alloc]initWithFrame:CGRectZero];
_imgView.backgroundColor = [UIColor clearColor];
_imgView.hidden = YES;
}
return _imgView;
}
- (UILabel*)destLabel {
if (!_destLabel) {
_destLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_destLabel.backgroundColor = [UIColor clearColor];
_destLabel.textAlignment = NSTextAlignmentLeft;
_destLabel.textColor = [UIColor colorWithHexString:StrongRelateDesc];
_destLabel.lineBreakMode = NSLineBreakByWordWrapping;
_destLabel.numberOfLines = 0;
}
_destLabel.font = appFont(imageDescFontSize, NO);
return _destLabel;
}
- (void)clickVideo:(UITapGestureRecognizer*)tapGesture {
if ([delegate conformsToProtocol:@protocol(videoCellDelegate)] &&
[delegate respondsToSelector:@selector(clickToPlayVideo:indexPath:)]) {
CGRect videoFrame = self.imgView.bounds;
// if (isIOS8) {
// videoFrame = self.imgView.bounds;
// }else videoFrame = CGRectMake(0, 0, CGRectGetHeight(self.imgView.bounds), CGRectGetWidth(self.imgView.bounds));
[delegate clickToPlayVideo:videoFrame indexPath:self.indexPath];
}
}
- (void)layoutSubviews {
[super layoutSubviews];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
CGSize size = CGSizeMake(600, 338);
CGFloat height = returnTextHeightWithRTLabel(self.videoBO.name, 1320/2, appFont(15, NO), 5);
CGFloat padding = 0;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
padding = 125;
}
dispatch_async(dispatch_get_main_queue(), ^{
if (self.imageBO) {
self.imgView.frame = CGRectMake(1320/4-1.1*size.width/2+padding, 0, size.width*1.1, size.height*1.1);
}
self.destLabel.frame = CGRectMake(padding,
CGRectGetMaxY(self.imgView.bounds)+5,
1320/2,
height+3);
if (self.imgView.hidden) {
self.imgView.hidden = NO;
}
self.videoImage.frame = CGRectMake(CGRectGetWidth(self.imgView.bounds)-118,
CGRectGetHeight(self.imgView.bounds)-113,
75, 75);//【需求】视频:水印修改(bug:4353)
});
});
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
|