expensiveGiftV.m 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // expensiveGiftV.m
  3. // yunbaolive
  4. //
  5. // Created by 王敏欣 on 2017/1/9.
  6. // Copyright © 2017年 cat. All rights reserved.
  7. //
  8. #import "expensiveGiftV.h"
  9. #import "SDWebImageManager.h"
  10. @implementation expensiveGiftV
  11. -(instancetype)init{
  12. self = [super init];
  13. self.frame = CGRectMake(0, 0, _window_width, _window_height);
  14. if (self) {
  15. _haohuaCount = 0;
  16. _expensiveGiftCount = [NSMutableArray array];
  17. }
  18. return self;
  19. }
  20. -(void)sethaohuacount{
  21. if (_haohuaCount == 0) {
  22. _haohuaCount =1;
  23. }
  24. else{
  25. _haohuaCount = 0;
  26. }
  27. }
  28. -(void)addArrayCount:(NSDictionary *)dic{
  29. [_expensiveGiftCount addObject:dic];
  30. }
  31. -(void)stopHaoHUaLiwu{
  32. [expensiveGiftTime invalidate];
  33. expensiveGiftTime = nil;
  34. _expensiveGiftCount = nil;
  35. }
  36. -(void)enGiftEspensive{
  37. if (_expensiveGiftCount.count == 0 || _expensiveGiftCount == nil) {//判断队列中有item且不是满屏
  38. [expensiveGiftTime invalidate];
  39. expensiveGiftTime = nil;
  40. return;
  41. }
  42. NSDictionary *Dic = [_expensiveGiftCount firstObject];
  43. [_expensiveGiftCount removeObjectAtIndex:0];
  44. [self expensiveGiftPopView:Dic];
  45. }
  46. -(void)expensiveGiftPopView:(NSDictionary *)giftData{
  47. CGFloat seconds = [[giftData valueForKey:@"swftime"] floatValue];
  48. [self sethaohuacount];
  49. if ([minstr([giftData valueForKey:@"swftype"]) isEqual:@"1"]) {
  50. SVGAParser *parser = [[SVGAParser alloc] init];
  51. [parser parseWithURL:[NSURL URLWithString:minstr([giftData valueForKey:@"swf"])] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
  52. gifView = [[exoensiveGifGiftV alloc]initWithGiftData:giftData andVideoitem:videoItem];
  53. [self addSubview:gifView];
  54. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(seconds * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  55. [gifView removeFromSuperview];
  56. [self sethaohuacount];
  57. if (_expensiveGiftCount.count >0) {
  58. [self.delegate expensiveGiftdelegate:nil];
  59. }
  60. });
  61. } failureBlock:nil];
  62. }else{
  63. gifView = [[exoensiveGifGiftV alloc]initWithGiftData:giftData andVideoitem:nil];
  64. [self addSubview:gifView];
  65. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(seconds * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  66. [gifView removeFromSuperview];
  67. [self sethaohuacount];
  68. if (_expensiveGiftCount.count >0) {
  69. [self.delegate expensiveGiftdelegate:nil];
  70. }
  71. });
  72. }
  73. }
  74. - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
  75. UIView *hitView = [super hitTest:point withEvent:event];
  76. if(hitView == self){
  77. return nil;
  78. }
  79. return hitView;
  80. }
  81. @end