-
Notifications
You must be signed in to change notification settings - Fork 0
/
AVFVideoCell.m
77 lines (63 loc) · 2.07 KB
/
AVFVideoCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// AVFVideoCell.m
// AwesomeVimeoFeed
//
// Created by Juan Manuel Serruya on 3/22/14.
// Copyright (c) 2014 Juan Manuel Serruya. All rights reserved.
//
#import "AVFVideoCell.h"
#import "UIImageView+AFNetworking.h"
#import "AVFVideoPreviewModel.h"
@implementation AVFVideoCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (IBAction)playButton:(id)sender
{
NSLog(@"Not Implemented");
}
- (void)setData:(AVFVideoPreviewModel*)data
{
self.userName.text = data.userName;
[self.userPortrait setImageWithURL:[NSURL URLWithString:data.userPortrait]
placeholderImage:nil];
self.videoUploadDate.text = [self formatDate:data.videoUploadDate];
[self.videoThumb setImageWithURL:[NSURL URLWithString:data.videoThumb]
placeholderImage:nil];
self.videoDescription.text = [self stringByStrippingHTML:data.videoDescription];
self.videoTitle.text = data.videoTitle;
}
- (NSString*)formatDate:(NSString*)date
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *dt = [formatter dateFromString:date];
[formatter setDateStyle:NSDateFormatterFullStyle];
NSString *dateAsString = [formatter stringFromDate:dt];
return dateAsString;
}
#pragma mark - Remove HTML Tags
- (NSString *)stringByStrippingHTML:(NSString *)inputString
{
NSMutableString *outString = [[NSMutableString alloc] initWithString:inputString];
if ([inputString length] > 0)
{
NSRange r;
while ((r = [outString rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound)
{
[outString deleteCharactersInRange:r];
}
}
return outString;
}
@end