

#import "FormatBestView.h"
#import "SnowRedDeepSeeCell.h"
#import "UIImageView+WebCache.h"
#import "UIView+WebCache.h"

@interface FormatBestView ()
@property (nonatomic, strong) UIImageView *alertHexSplatImageView;
@end

@implementation FormatBestView

- (void)opacityGenreGroupingYouUtteranceDiscardedModel:(UnboundAlertInfo *)model {
[self norwegianCheckedSonReportedGrowFontGrowModel:model];
    NSMutableArray *black = [NSMutableArray new];
    for (int i = 0; i<model.kinRetGray; i++) {
        SnowRedDeepSeeCell *foot = [[SnowRedDeepSeeCell alloc]init];
        foot.oddStepStart = model.mainRecord;
        foot.channelCount = 1;
        foot.saySob = 6;
        foot.minimizeInvite = CGFLOAT_MIN;
        CGRect homeRect = [model.waySeasonCar boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:model.youProjectParameterInsertionSharpnessDanish] forKey:NSFontAttributeName] context:nil];
        foot.chamberSize = CGSizeMake(homeRect.size.width+8, homeRect.size.height+4);
        foot.model = model;
        [black addObject:foot];
    }
    [self digestMinimize:black];
}

- (void)norwegianCheckedSonReportedGrowFontGrowModel:(UnboundAlertInfo *)model {
    NSString *url = model.secretAlbanianDebuggerSpellRunDrain;

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

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

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

- (void)usagePriorityImageView:(UIImageView *)bag image:(UIImage *)image {
    CGFloat width = self.bounds.size.width;
    CGFloat height = self.bounds.size.height;
    if (image.size.width > 0) {
        CGFloat daughters = image.size.height / image.size.width * width;
        
        CGFloat offsetY = (height - daughters) * 0.5;
        bag.frame = CGRectMake(0, offsetY, width, daughters);
    } else {
        bag.frame = self.bounds;
    }
}

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


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

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

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

@end
