WLNativeAdsCollectionMode.m
22.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
//
// WLNativeAdsCollectionMode.m
// DemoApp
//
// Created by Nick Xirotyris on 19/10/15.
// Copyright © 2015 YC. All rights reserved.
//
#import "WLNativeAdsCollectionMode.h"
#import "WLNativeAdCollectionViewCell.h"
#import "Warply.h"
@interface WLNativeAdsCollectionMode () <UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) id<UICollectionViewDataSource> originalDatasource;
@property (weak, nonatomic) id<UICollectionViewDelegate> originalDelegate;
@property (strong, nonatomic) id<UICollectionViewDelegateFlowLayout> originalFlowLayout;
@property (weak, nonatomic) UICollectionView *nativeCollectionView;
@property (nonatomic, weak) WLCustomNativeCollectionViewCell *customCell;
@property (nonatomic, strong) NSString *customCellIdentifier;
@property (nonatomic, strong) NSString *customCellNibName;
@property (weak, nonatomic) UIViewController <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout> *originalVC;
@end
@implementation WLNativeAdsCollectionMode {
NSInteger adsForCollectionView;
NSInteger startAd;
NSInteger frequencyAd;
NSInteger originalNumberOfsections;
NSInteger currentRows;
NSInteger totalExtraRows;
NSMutableArray *indexArrayOfAds;
NSArray *offersArray;
CGSize cellSize;
NSString *display_type;
BOOL repeatableAds;
}
-(id)initWithViewController:(UIViewController<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout> *)viewController CollectionView:(UICollectionView *)collectionView withStartPosition:(NSInteger)startPosition Frequency:(NSInteger)frequency CellSize:(CGSize)size andDisplayType:(NSString *)displayType{
self = [super init];
if (self) {
[self getInbox];
[self.nativeCollectionView registerClass:[WLNativeAdCollectionViewCell class] forCellWithReuseIdentifier:@"adItem"];
[collectionView registerClass:[WLNativeAdCollectionViewCell class] forCellWithReuseIdentifier:@"adItem"];
self.originalDatasource = collectionView.dataSource;
self.originalDelegate = collectionView.delegate;
self.nativeCollectionView = collectionView;
self.originalVC = viewController;
self.originalFlowLayout = (id<UICollectionViewDelegateFlowLayout>)self.originalDelegate;
startAd = startPosition;
frequencyAd = frequency;
display_type = displayType;
if ([self.originalDatasource respondsToSelector:@selector(numberOfSectionsInCollectionView:)]) {
originalNumberOfsections = [self.originalDatasource numberOfSectionsInCollectionView:collectionView];
} else {
originalNumberOfsections = 1;
}
repeatableAds = NO;
currentRows = 0;
totalExtraRows = 0;
cellSize = size;
}
return self;
}
- (void)refreshAdsForCollectionView:(UICollectionView *)collectionView {
self.originalDatasource = nil;
self.originalDelegate = nil;
self.nativeCollectionView = nil;
collectionView.dataSource = nil;
collectionView.delegate = nil;
collectionView.dataSource = self.originalVC;
collectionView.delegate = self.originalVC;
self.originalDatasource = collectionView.dataSource;
self.originalDelegate = collectionView.delegate;
self.nativeCollectionView = collectionView;
if ([self.originalDatasource respondsToSelector:@selector(numberOfSectionsInCollectionView:)]) {
originalNumberOfsections = [self.originalDatasource numberOfSectionsInCollectionView:collectionView];
} else {
originalNumberOfsections = 1;
}
currentRows = 0;
totalExtraRows = 0;
[self getInbox];
}
-(void)setRepeatable:(BOOL)repeatable {
repeatableAds = repeatable;
if (!repeatable) {
int counter = 0;
for (int i = 0; i < originalNumberOfsections; i++) {
for (int j = 0; j < [[indexArrayOfAds objectAtIndex:i] count]; j++) {
if ([[[indexArrayOfAds objectAtIndex:i] objectAtIndex:j] isEqual:@(YES)]) {
counter++;
if (counter > adsForCollectionView) {
[[indexArrayOfAds objectAtIndex:i] removeObjectAtIndex:j];
}
}
}
}
[self.nativeCollectionView reloadData];
} else {
NSLog(@"Nothing to remove");
}
}
-(void)setCustomCellForNativeAd:(WLCustomNativeCollectionViewCell *)cell withIdentifier:(NSString *)cellIdentifier andNibName:(NSString *)nibName {
self.customCell = cell;
self.customCellIdentifier = cellIdentifier;
self.customCellNibName = nibName;
}
-(void)getInbox {
[[Warply sharedService] getInboxWithSuccessBlock:^(NSArray *list) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"(display_type == '%@')", display_type]];
offersArray = [list filteredArrayUsingPredicate:predicate];
if (offersArray.count > 0) {
[self setupNewRowsPerSection];
[self setRepeatable:repeatableAds];
self.nativeCollectionView.dataSource = self;
self.nativeCollectionView.delegate = self;
self.nativeCollectionView.allowsSelection = YES;
[self.nativeCollectionView reloadData];
}
} failureBlock:^(NSError *error) {
//
}];
}
#pragma mark - Original IndexPath & Helpers
- (void)setupNewRowsPerSection {
indexArrayOfAds = [NSMutableArray array];
int count = 0;
for (int i = 0; i < originalNumberOfsections; i++) {
NSMutableArray *newRows = [NSMutableArray array];
NSInteger total = [self totalRowsWithAdsForSection:i];
for (int j = 0; j < total; j++) {
if (count == startAd || (count > startAd && (count - startAd)%(frequencyAd + 1) == 0)) {
[newRows addObject:@(YES)];
} else {
[newRows addObject:@(NO)];
}
count++;
}
[indexArrayOfAds addObject:newRows];
}
NSLog(@"%@", indexArrayOfAds);
}
-(NSInteger)totalRowsWithAdsForSection:(int)section {
NSInteger originalRows = [self.originalDatasource collectionView:self.nativeCollectionView numberOfItemsInSection:section];
currentRows += originalRows;
if (currentRows < startAd) {
return originalRows;
} else {
if (startAd + 1 >= currentRows - originalRows && startAd + 1 <= currentRows) {
NSInteger extraRows = (currentRows - startAd)/frequencyAd + 1;
totalExtraRows += extraRows;
return extraRows + originalRows;
} else {
NSInteger extraRowsSoFar = (currentRows - startAd)/frequencyAd + 1;
NSInteger extraRowsForSection = extraRowsSoFar - totalExtraRows;
totalExtraRows += extraRowsForSection;
return originalRows + extraRowsForSection;
}
}
}
-(NSIndexPath *)getOriginalIndexPath:(NSIndexPath *)indexPath {
int extraRows = 0;
for (int i = 0; i < indexPath.row; i++) {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:i] isEqual:@(YES)]) {
extraRows++;
}
}
// NSLog(@"row: %ld", (long)indexPath.row - extraRows);
return [NSIndexPath indexPathForRow:indexPath.row - extraRows inSection:indexPath.section];
}
-(int)getIndexOfAd:(NSIndexPath *)indexPath {
int adsCount = 0;
for (int i = 0; i < indexPath.section + 1; i++) {
int rows = 0;
if (indexPath.section > i) {
rows = (int)[[indexArrayOfAds objectAtIndex:i] count];
} else {
rows = (int)indexPath.row + 1;
}
for (int j = 0; j < rows; j++) {
if ([[[indexArrayOfAds objectAtIndex:i] objectAtIndex:j] isEqual:@(YES)]) {
adsCount++;
}
}
}
if (adsCount == offersArray.count) {
return adsCount-1;
} else {
return adsCount%offersArray.count - 1;
}
}
#pragma mark - CollectionView Datasource
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return originalNumberOfsections;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [[indexArrayOfAds objectAtIndex:section] count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
if (self.customCell) {
NSString *customIdentifier = [NSString stringWithFormat:@"%@", self.customCellIdentifier];
WLCustomNativeCollectionViewCell *customCell = (WLCustomNativeCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:customIdentifier forIndexPath:indexPath];
if (self.customCellNibName) {
if (customCell == nil) {
customCell = [[[NSBundle mainBundle] loadNibNamed:[NSString stringWithFormat:@"%@", self.customCellNibName] owner:self options:nil] objectAtIndex:0];
}
}
if (offersArray.count > 0) {
WLInboxItem *item = (WLInboxItem *)offersArray[[self getIndexOfAd:indexPath]];
[customCell setupCustomCell:item];
}
return customCell;
} else {
WLNativeAdCollectionViewCell *cell = (WLNativeAdCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"adItem" forIndexPath:indexPath];
if (cell == nil) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"WLNativeAdCollectionViewCell" owner:self options:nil] objectAtIndex:0];
}
cell.backgroundColor = [UIColor whiteColor];
WLInboxItem *item = (WLInboxItem *)offersArray[[self getIndexOfAd:indexPath]];
[cell loadContentwithURL:[item getPageURL]];
return cell;
}
} else {
return [self.originalDatasource collectionView:self.nativeCollectionView cellForItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
#pragma mark - CollectionView Delegate
-(BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return NO;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:canPerformAction:forItemAtIndexPath:withSender:)]) {
return [self.originalDelegate collectionView:self.nativeCollectionView canPerformAction:(SEL)action forItemAtIndexPath:[self getOriginalIndexPath:indexPath] withSender:sender];
}
return NO;
}
}
-(void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:performAction:forItemAtIndexPath:withSender:)]) {
[self.originalDelegate collectionView:self.nativeCollectionView performAction:(SEL)action forItemAtIndexPath:[self getOriginalIndexPath:indexPath] withSender:sender];
}
}
}
-(void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:didDeselectItemAtIndexPath:)]) {
return [self.originalDelegate collectionView:self.nativeCollectionView didDeselectItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
if (offersArray.count > 0) {
WLInboxItem *item = (WLInboxItem *)offersArray[[self getIndexOfAd:indexPath]];
if ([[self delegate] respondsToSelector:@selector(nativeAdDidSelectWithItem:)]) {
[[self delegate] nativeAdDidSelectWithItem:item];
}
}
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:didSelectItemAtIndexPath:)]) {
[self.originalDelegate collectionView:self.nativeCollectionView didSelectItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
}
-(void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:didHighlightItemAtIndexPath:)]) {
return [self.originalDelegate collectionView:self.nativeCollectionView didHighlightItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
}
-(void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:didUnhighlightItemAtIndexPath:)]) {
return [self.originalDelegate collectionView:self.nativeCollectionView didUnhighlightItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
}
-(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
//FIXME: wrong conditions
// if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
// return NO;
// } else {
// if ([self.originalDelegate respondsToSelector:@selector(collectionView:shouldSelectItemAtIndexPath:)]) {
// return [self.originalDelegate collectionView:self.nativeCollectionView shouldSelectItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
// }
// }
return YES;
}
-(BOOL)collectionView:(UICollectionView *)collectionView shouldDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
// if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
// return NO;
// } else {
// if ([self.originalDelegate respondsToSelector:@selector(collectionView:shouldDeselectItemAtIndexPath:)]) {
// return [self.originalDelegate collectionView:self.nativeCollectionView shouldDeselectItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
// }
// }
return YES;
}
-(BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath {
//FIXME: wrong conditions
// if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
// return NO;
// } else {
// if ([self.originalDelegate respondsToSelector:@selector(collectionView:shouldHighlightItemAtIndexPath:)]) {
// return [self.originalDelegate collectionView:self.nativeCollectionView shouldHighlightItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
// }
// }
//
// return NO;
return YES;
}
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return NO;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:shouldShowMenuForItemAtIndexPath:)]) {
return [self.originalDelegate collectionView:self.nativeCollectionView shouldShowMenuForItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
return NO;
}
-(void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:willDisplayCell:forItemAtIndexPath:)]) {
return [self.originalDelegate collectionView:self.nativeCollectionView willDisplayCell:cell forItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
}
-(void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:didEndDisplayingCell:forItemAtIndexPath:)]) {
return [self.originalDelegate collectionView:self.nativeCollectionView didEndDisplayingCell:cell forItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
}
-(void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:willDisplaySupplementaryView:forElementKind:atIndexPath:)]) {
return [self.originalDelegate collectionView:self.nativeCollectionView willDisplaySupplementaryView:view forElementKind:elementKind atIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
}
-(void)collectionView:(UICollectionView *)collectionView didEndDisplayingSupplementaryView:(UICollectionReusableView *)view forElementOfKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:didEndDisplayingSupplementaryView:forElementOfKind:atIndexPath:)]) {
return [self.originalDelegate collectionView:self.nativeCollectionView didEndDisplayingSupplementaryView:view forElementOfKind:elementKind atIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
}
#pragma mark - CollectionView Flow Layout
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
if ([self.originalFlowLayout respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)]) {
return [self.originalFlowLayout collectionView:self.nativeCollectionView layout:collectionViewLayout insetForSectionAtIndex:section];
}
return UIEdgeInsetsZero;
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
if ([self.originalFlowLayout respondsToSelector:@selector(collectionView:layout:minimumInteritemSpacingForSectionAtIndex:)]) {
return [self.originalFlowLayout collectionView:self.nativeCollectionView layout:collectionViewLayout minimumInteritemSpacingForSectionAtIndex:section];
}
return 10;
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
if ([self.originalFlowLayout respondsToSelector:@selector(collectionView:layout:minimumLineSpacingForSectionAtIndex:)]) {
return [self.originalFlowLayout collectionView:self.nativeCollectionView layout:collectionViewLayout minimumLineSpacingForSectionAtIndex:section];
}
return 10;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
if ([self.originalFlowLayout respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)]) {
return [self.originalFlowLayout collectionView:self.nativeCollectionView layout:collectionViewLayout referenceSizeForFooterInSection:section];
}
return CGSizeZero;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
if ([self.originalFlowLayout respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)]) {
return [self.originalFlowLayout collectionView:self.nativeCollectionView layout:collectionViewLayout referenceSizeForHeaderInSection:section];
}
return CGSizeZero;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
if ([[[indexArrayOfAds objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] isEqual:@(YES)]) {
return cellSize;
} else {
if ([self.originalDelegate respondsToSelector:@selector(collectionView:layout:sizeForItemAtIndexPath:)]) {
return [self.originalFlowLayout collectionView:self.nativeCollectionView layout:collectionViewLayout sizeForItemAtIndexPath:[self getOriginalIndexPath:indexPath]];
}
}
UICollectionViewFlowLayout *flow = (UICollectionViewFlowLayout *)collectionView.collectionViewLayout;
return flow.itemSize;
}
@end