

#import "LiveAgeAskView.h"
#import "FootFatJoinRunCell.h"
#import "UIImageView+WebCache.h"
#import "UIView+WebCache.h"

@interface LiveAgeAskView ()
@property (nonatomic, strong) UIImageView *appendingExecImageView;
@end

@implementation LiveAgeAskView

- (void)canNotDescendedFootballSpotlightMouthModel:(AreOutletOneInfo *)model {

    NSMutableArray *space = [NSMutableArray new];
    for (int i = 0; i<model.browseBurn; i++) {
        FootFatJoinRunCell *turn = [[FootFatJoinRunCell alloc]init];
        turn.zeroShePivot = model.busSeconds;
        turn.channelCount = 1;
        turn.expect = 6;
        turn.fileMileMixBit = CGFLOAT_MIN;
        CGRect artsRect = [model.milePrepared boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:model.pubDownloadZipTrapEntropyDeferring] forKey:NSFontAttributeName] context:nil];
        turn.beaconsSize = CGSizeMake(artsRect.size.width+8, artsRect.size.height+4);
        turn.model = model;
        [space addObject:turn];
    }
    [self writeSatisfied:space];
}

- (void)encodingRationalMostHaveSwapDepthMusicianModel:(AreOutletOneInfo *)model {
    NSString *url = model.causeMatchMaxSunBayerHall;

    if (url.length == 0) {
        _appendingExecImageView.hidden = YES;
        _appendingExecImageView.image = nil;
        return;
    }

    UIImageView *she = self.appendingExecImageView;
    she.hidden = NO;
    if (she.superview != self) {
        [self insertSubview:she atIndex:0];
    } else {
        [self sendSubviewToBack:she];
    }

    [she sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        if (image) [self loveAnyOptMidImageView:she image:image];
    }];
}

- (void)loveAnyOptMidImageView:(UIImageView *)she image:(UIImage *)image {
    CGFloat width = self.bounds.size.width;
    CGFloat height = self.bounds.size.height;
    if (image.size.width > 0) {
        CGFloat oddMethod = image.size.height / image.size.width * width;
        
        CGFloat oddMole = (height - oddMethod) * 0.5;
        she.frame = CGRectMake(0, oddMole, width, oddMethod);
    } else {
        she.frame = self.bounds;
    }
}

- (UIImageView *)appendingExecImageView {
    if (!_appendingExecImageView) {
        _appendingExecImageView = [[UIImageView alloc] init];
        _appendingExecImageView.contentMode = UIViewContentModeScaleToFill;
        _appendingExecImageView.userInteractionEnabled = NO;
        _appendingExecImageView.clipsToBounds = NO;
    }
    return _appendingExecImageView;
}


- (void)messageGreatFootballRedoSinkInactive {
    if (_appendingExecImageView) {
        [_appendingExecImageView sd_cancelLatestImageLoad];
        [_appendingExecImageView removeFromSuperview];
        _appendingExecImageView.image = nil;
        _appendingExecImageView = nil;
    }
}

- (void)stop {
    [super stop];
    [self messageGreatFootballRedoSinkInactive];
}

- (void)removeFromSuperview {
    [self messageGreatFootballRedoSinkInactive];
    [super removeFromSuperview];
}

@end
