








#import "AnyFoodMoveAnd.h"

#define CampaignPrice self.frame.size.width

@interface AnyFoodMoveAnd()



@property (nonatomic, strong) NSMutableArray                            *tooPackArray;



@property (nonatomic, strong) NSMutableArray <AssumeGramEastCell *>      *mustArray;



@property (strong, nonatomic) NSMutableArray <AssumeGramEastCell *>      *mediumCenter;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) CatalogSymbolTeacherVitaminElevation                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   weekly;

@end

@implementation AnyFoodMoveAnd

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.status = CopperPreciseArrayDisablesStepperBusy;
    }
    return self;
}

- (void)lazyNoiseUse
{
    
    if (self.mustArray.firstObject) {
        
        
        AssumeGramEastCell *literalView = self.mustArray.firstObject;
        
        literalView.frame = CGRectMake(CampaignPrice, 0, literalView.stoppedSize.width, literalView.stoppedSize.height);
        
        self.weekly = literalView.weekly;
        
        self.channelCount = literalView.channelCount;
        
        
        NSInteger row = [self zipBriefCanonBadgeEthernetDeviationRole:literalView];
        
        
        if (row >= 0) {
            
            
            [self.mustArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:literalView]) {
                [self addSubview:literalView];
            }
            literalView.frame = CGRectMake(CampaignPrice,  row * (literalView.stoppedSize.height + _weekly), literalView.stoppedSize.width, literalView.stoppedSize.height);
            
            
            [_tooPackArray setObject:literalView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(milesHourOutView:willDisplayCell:)]) {
                [self.delegate milesHourOutView:self willDisplayCell:literalView];
            }
            
            
            [self.mediumCenter addObject:literalView];
            
            [literalView layeringUserStaticRecognizeWeek:^{
                
                
                [literalView setTransform:CGAffineTransformMakeTranslation(- literalView.frame.size.width-CampaignPrice, 0)];
                
            } completion:^(BOOL finished) {
                
                [literalView removeFromSuperview];
                
                
                [self.mediumCenter removeObject:literalView];
                
                
                if ([self.delegate respondsToSelector:@selector(milesHourOutView:didEndDisplayingCell:)]) {
                    [self.delegate milesHourOutView:self didEndDisplayingCell:literalView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(fairVignetteBeginningSystolicHueOfferDirectMedium:)]) {
                        [self.delegate fairVignetteBeginningSystolicHueOfferDirectMedium:self];
                    }
                    self.count = 0;
                }
                
                

            }];
        }
    }
    
    [self performSelector:@selector(lazyNoiseUse) withObject:nil afterDelay:0.45f];
}


- (void)artMustManyHis:(NSArray <AssumeGramEastCell *> *)barrages
{
    self.count += barrages.count;
    [self.mustArray addObjectsFromArray:barrages];
}

- (void)start
{
    if (self.status == TogglePositionsChargeLeapMiterClose) {
        return;
    }
    self.status = TogglePositionsChargeLeapMiterClose;
    
    [self lazyNoiseUse];
}

- (void)stop
{
    if (self.status == CopperPreciseArrayDisablesStepperBusy) {
        return;
    }
    self.status = CopperPreciseArrayDisablesStepperBusy;
    
    if (self.mediumCenter.count) {
        [self.mediumCenter makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.mustArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.mediumCenter  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.mediumCenter  removeAllObjects];
    [self.mustArray     removeAllObjects];
    [self.tooPackArray  removeAllObjects];
    
    self.mediumCenter       = nil;
    self.mustArray          = nil;
    self.tooPackArray       = nil;
}


- (NSInteger)zipBriefCanonBadgeEthernetDeviationRole:(AssumeGramEastCell *)newBarrage
{
    for (int row = 0; row<_tooPackArray.count; row++) {
        NSObject *object = _tooPackArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[AssumeGramEastCell class]]) { 
            
            AssumeGramEastCell *pagerArrow = (AssumeGramEastCell*)object;
            
            if ([self zipBriefCanonBadgeEthernetDeviationRole:pagerArrow sinFlight:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)zipBriefCanonBadgeEthernetDeviationRole:(AssumeGramEastCell *)pagerArrow sinFlight:(AssumeGramEastCell *)newBarrage
{
    
    if (pagerArrow.status == InviteReportLearnRestThumbHow) {
        return NO;
    }
    
    
    CGRect rect = [pagerArrow.layer.presentationLayer frame];
    if (rect.origin.x>CampaignPrice - pagerArrow.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (pagerArrow.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = CampaignPrice/(CampaignPrice+newBarrage.frame.size.width)*newBarrage.tenCubeNonce;
        
        CGFloat bold = rect.origin.x - time/(pagerArrow.tenCubeNonce)*(CampaignPrice + pagerArrow.frame.size.width);
        if (bold < -pagerArrow.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *malay = [touches anyObject];
    CGPoint handledMen  = [malay locationInView:self];
    for (UIView *bitPick in [self subviews])
    {
        if (![bitPick isKindOfClass:[AssumeGramEastCell class]]) continue;
        AssumeGramEastCell *literalView = (AssumeGramEastCell *)bitPick;
        if ([literalView.layer.presentationLayer hitTest:handledMen])
        {
            
            if ([self.delegate respondsToSelector:@selector(milesHourOutView:capRateWorkCell:)]) {
                [self.delegate milesHourOutView:self capRateWorkCell:literalView];
            }
            break;
        }
    }
}




- (NSMutableArray<AssumeGramEastCell *> *)mustArray {
    if (!_mustArray) {
        _mustArray = [[NSMutableArray alloc] init];
    }
    return _mustArray;
}


- (NSMutableArray<AssumeGramEastCell *> *)mediumCenter {
    if (!_mediumCenter) {
        _mediumCenter = [[NSMutableArray alloc] init];
    }
    return _mediumCenter;
}


- (void)setChannelCount:(NSInteger)channelCount
{
    
    if (self.tooPackArray.count < channelCount) { 
        
        for (NSInteger row = self.tooPackArray.count; row < channelCount; row++) {
            NSNumber *number = [NSNumber numberWithBool:YES];
            [self.tooPackArray setObject:number atIndexedSubscript:row];
        }
        
    }else {
        
        for (NSInteger row = channelCount; row < self.tooPackArray.count; row++) {
            [self.tooPackArray removeObjectAtIndex:row];
        }
    }
    
    _channelCount = channelCount;
    
}


- (NSMutableArray *)tooPackArray {
    if (!_tooPackArray) {
        _tooPackArray = [[NSMutableArray alloc] init];
    }
    return _tooPackArray;
}

@end
