

#import "HoverIdiomView.h"
#import "SpaYardEndsBinCell.h"
#import "UIImageView+WebCache.h"
#import "UIView+WebCache.h"

@interface HoverIdiomView ()
@property (nonatomic, strong) UIImageView *arrowTabStartImageView;
@end

@implementation HoverIdiomView

- (void)netYardGetOppositeHourPrintableModel:(TapJabberPubInfo *)model {

    NSMutableArray *torch = [NSMutableArray new];
    for (int i = 0; i<model.airSentFit; i++) {
        SpaYardEndsBinCell *best = [[SpaYardEndsBinCell alloc]init];
        best.redPurpleOwn = model.barFarTrad;
        best.channelCount = 1;
        best.asleep = 6;
        best.partRomanAlien = CGFLOAT_MIN;
        CGRect loveRect = [model.itsStereoRet boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:model.generateFaceRearTryDirectoryMicro] forKey:NSFontAttributeName] context:nil];
        best.malePinSize = CGSizeMake(loveRect.size.width+8, loveRect.size.height+4);
        best.model = model;
        [torch addObject:best];
    }
    [self mustSolidHeart:torch];
}

- (void)inventoryBodyCostObscuredWasSyntaxGreenModel:(TapJabberPubInfo *)model {
    NSString *url = model.millBrushNineProgressStripUse;

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

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

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

- (void)segueNotTatarImageView:(UIImageView *)egg image:(UIImage *)image {
    CGFloat width = self.bounds.size.width;
    CGFloat height = self.bounds.size.height;
    if (image.size.width > 0) {
        CGFloat tooPolish = image.size.height / image.size.width * width;
        
        CGFloat wakeRet = (height - tooPolish) * 0.5;
        egg.frame = CGRectMake(0, wakeRet, width, tooPolish);
    } else {
        egg.frame = self.bounds;
    }
}

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


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

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

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

@end
