Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 3.45 KB | None | 0 0
  1. -(void)onStickerImageTap:(UITapGestureRecognizer*)gesture {
  2.     UIImageView *stickerImage = (UIImageView *)gesture.view;
  3.     PTChatStreamModel *model = [chatStream objectAtIndex:stickerImage.tag];
  4.    
  5.     if ([model isKindOfClass:[PTChatMessageModel class]]) {
  6.         PTChatMessageModel *messageModel = (PTChatMessageModel *)model;
  7.         tappedStickerId = messageModel.stickerId;
  8.         if (messageModel.messageType==PTChatMessageTypeSticker) {
  9.             PTVGiftManager *giftManager = [PTVGiftManager sharedInstance];
  10.             PTStickerManager *stickerManager = [PTStickerManager sharedInstance];
  11.  
  12.            
  13.             __weak __typeof(self)weakSelf = self;
  14.  
  15.             [stickerManager getMyStickerPacksWithCompletion:^(NSArray<PTStickerPack *> * _Nullable packs) {
  16.                 if (packs && packs.count > 0) {
  17.                    
  18.                     __block int count = 0;
  19.  
  20.  
  21.                     [stickerManager getAndCacheStickersWithStickerPackId:tappedStickerId completion:^(PTStickerPack *selectedStickerPack ) {
  22.  
  23.                        
  24.                         __strong typeof(self)strongSelf = weakSelf;
  25.  
  26.  
  27.                         if (count == 0) {
  28.                             if([packs containsObject:selectedStickerPack]) {
  29.                                 [stickerAlert addAction:[UIAlertAction actionWithTitle:kLocalizedString_OK style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  30.                                     [strongSelf showStickerPickerPopup];
  31.                                 }]];
  32.                                 [strongSelf presentViewController:stickerAlert animated:YES completion:nil];
  33.                             } else {
  34.  
  35.                                 //navigate to detailed gift view
  36.  
  37.                                 [giftManager fetchAllGiftsWithBlock:^(PTVGiftCategoryModel *model, NSError *error) {
  38.  
  39.                                     __strong typeof(self)strongSelf = weakSelf;
  40.    
  41.                                     if ((arrCategory && arrCategory.count > 0) && (model.gifts && model.gifts.count > 0)) {
  42.                                        
  43.                                                     giftWebVC.delegate = strongSelf;
  44.                                                     giftWebVC.giftUrl = vgiftData.sponsorUrl;
  45.                                                     giftWebVC.giftName = vgiftData.description;
  46.                                                     _vgiftData = vgiftData;
  47.                                                     [strongSelf presentViewController:giftWebVC animated:YES completion:nil];
  48.                                                 } else {
  49.                                                     [strongSelf showGiftDetailsController:vgiftData];
  50.                                                 }
  51.                                             } else {
  52.                                                 [strongSelf showStickerPickerPopup];
  53.                                             }
  54.                                            
  55.                                         } else {
  56.                                             //gift not available navigate to market place screen
  57.                                             [strongSelf showStickerPickerPopup];
  58.                                         }
  59.                                     }
  60.                                 }];
  61.                             }
  62.                         }
  63.                     }];
  64.                 }
  65.                 return;
  66.             }];
  67.         }
  68.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement