9
9
#import " IMYAOPCollectionViewUtils+Delegate.h"
10
10
#import " IMYAOPCollectionViewUtils+Private.h"
11
11
12
- #define kAOPRealIndexPathCode \
12
+ #define kAOPUserIndexPathCode \
13
13
NSIndexPath *userIndexPath = [self userIndexPathByFeeds: indexPath]; \
14
14
id <IMYAOPCollectionViewDelegate> delegate = nil ; \
15
15
if (userIndexPath) { \
16
16
delegate = (id )self.origDelegate ; \
17
17
indexPath = userIndexPath; \
18
18
} else { \
19
19
delegate = self.delegate ; \
20
+ isInjectAction = YES ; \
21
+ } \
22
+ if (isInjectAction) { \
23
+ self.isUICalling += 1 ; \
20
24
}
21
25
22
- #define kAOPRealSectionCode \
26
+
27
+ #define kAOPUserSectionCode \
23
28
NSInteger userSection = [self userSectionByFeeds: section]; \
24
29
id <IMYAOPCollectionViewDelegate> delegate = nil ; \
25
30
if (userSection >= 0 ) { \
26
31
delegate = (id )self.origDelegate ; \
27
32
section = userSection; \
28
33
} else { \
29
34
delegate = self.delegate ; \
35
+ isInjectAction = YES ; \
36
+ } \
37
+ if (isInjectAction) { \
38
+ self.isUICalling += 1 ; \
30
39
}
31
40
32
- #define kAOPUICallingSaved \
41
+
42
+ #define kAOPUICallingSaved \
43
+ BOOL isInjectAction = NO ; \
33
44
self.isUICalling -= 1 ;
34
45
35
- #define kAOPUICallingResotre \
46
+ #define kAOPUICallingResotre \
47
+ if (isInjectAction) { \
48
+ self.isUICalling -= 1 ; \
49
+ } \
36
50
self.isUICalling += 1 ;
37
51
38
- #define kAOPDefineLayout
39
-
40
52
@implementation IMYAOPCollectionViewUtils (UITableViewDelegate)
41
53
42
54
- (BOOL )collectionView : (UICollectionView *)collectionView shouldHighlightItemAtIndexPath : (NSIndexPath *)indexPath {
43
55
kAOPUICallingSaved ;
44
- kAOPRealIndexPathCode ;
56
+ kAOPUserIndexPathCode ;
45
57
BOOL canHighlight = YES ;
46
58
if ([delegate respondsToSelector: @selector (collectionView:shouldHighlightItemAtIndexPath: )]) {
47
59
canHighlight = [delegate collectionView: collectionView shouldHighlightItemAtIndexPath: indexPath];
@@ -52,7 +64,7 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtI
52
64
53
65
- (void )collectionView : (UICollectionView *)collectionView didHighlightItemAtIndexPath : (NSIndexPath *)indexPath {
54
66
kAOPUICallingSaved ;
55
- kAOPRealIndexPathCode ;
67
+ kAOPUserIndexPathCode ;
56
68
if ([delegate respondsToSelector: @selector (collectionView:didHighlightItemAtIndexPath: )]) {
57
69
[delegate collectionView: collectionView didHighlightItemAtIndexPath: indexPath];
58
70
}
@@ -61,7 +73,7 @@ - (void)collectionView:(UICollectionView *)collectionView didHighlightItemAtInde
61
73
62
74
- (void )collectionView : (UICollectionView *)collectionView didUnhighlightItemAtIndexPath : (NSIndexPath *)indexPath {
63
75
kAOPUICallingSaved ;
64
- kAOPRealIndexPathCode ;
76
+ kAOPUserIndexPathCode ;
65
77
if ([delegate respondsToSelector: @selector (collectionView:didUnhighlightItemAtIndexPath: )]) {
66
78
[delegate collectionView: collectionView didUnhighlightItemAtIndexPath: indexPath];
67
79
}
@@ -70,7 +82,7 @@ - (void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIn
70
82
71
83
- (BOOL )collectionView : (UICollectionView *)collectionView shouldSelectItemAtIndexPath : (NSIndexPath *)indexPath {
72
84
kAOPUICallingSaved ;
73
- kAOPRealIndexPathCode ;
85
+ kAOPUserIndexPathCode ;
74
86
BOOL canSelected = YES ;
75
87
if ([delegate respondsToSelector: @selector (collectionView:shouldSelectItemAtIndexPath: )]) {
76
88
canSelected = [delegate collectionView: collectionView shouldSelectItemAtIndexPath: indexPath];
@@ -81,7 +93,7 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtInde
81
93
82
94
- (BOOL )collectionView : (UICollectionView *)collectionView shouldDeselectItemAtIndexPath : (NSIndexPath *)indexPath {
83
95
kAOPUICallingSaved ;
84
- kAOPRealIndexPathCode ;
96
+ kAOPUserIndexPathCode ;
85
97
BOOL canSelected = YES ;
86
98
if ([delegate respondsToSelector: @selector (collectionView:shouldDeselectItemAtIndexPath: )]) {
87
99
canSelected = [delegate collectionView: collectionView shouldDeselectItemAtIndexPath: indexPath];
@@ -92,7 +104,7 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldDeselectItemAtIn
92
104
93
105
- (void )collectionView : (UICollectionView *)collectionView didSelectItemAtIndexPath : (NSIndexPath *)indexPath {
94
106
kAOPUICallingSaved ;
95
- kAOPRealIndexPathCode ;
107
+ kAOPUserIndexPathCode ;
96
108
if ([delegate respondsToSelector: @selector (collectionView:didSelectItemAtIndexPath: )]) {
97
109
[delegate collectionView: collectionView didSelectItemAtIndexPath: indexPath];
98
110
}
@@ -101,7 +113,7 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
101
113
102
114
- (void )collectionView : (UICollectionView *)collectionView didDeselectItemAtIndexPath : (NSIndexPath *)indexPath {
103
115
kAOPUICallingSaved ;
104
- kAOPRealIndexPathCode ;
116
+ kAOPUserIndexPathCode ;
105
117
if ([delegate respondsToSelector: @selector (collectionView:didDeselectItemAtIndexPath: )]) {
106
118
[delegate collectionView: collectionView didDeselectItemAtIndexPath: indexPath];
107
119
}
@@ -114,7 +126,7 @@ - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICol
114
126
if ([self .delegate respondsToSelector: @selector (aopCollectionUtils:willDisplayCell:forItemAtIndexPath: )]) {
115
127
[self .delegate aopCollectionUtils: self willDisplayCell: cell forItemAtIndexPath: indexPath];
116
128
}
117
- kAOPRealIndexPathCode ;
129
+ kAOPUserIndexPathCode ;
118
130
if ([delegate respondsToSelector: @selector (collectionView:willDisplayCell:forItemAtIndexPath: )]) {
119
131
[delegate collectionView: collectionView willDisplayCell: cell forItemAtIndexPath: indexPath];
120
132
}
@@ -123,7 +135,7 @@ - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICol
123
135
124
136
- (void )collectionView : (UICollectionView *)collectionView willDisplaySupplementaryView : (UICollectionReusableView *)view forElementKind : (NSString *)elementKind atIndexPath : (NSIndexPath *)indexPath {
125
137
kAOPUICallingSaved ;
126
- kAOPRealIndexPathCode ;
138
+ kAOPUserIndexPathCode ;
127
139
if ([delegate respondsToSelector: @selector (collectionView:willDisplaySupplementaryView:forElementKind:atIndexPath: )]) {
128
140
[delegate collectionView: collectionView willDisplaySupplementaryView: view forElementKind: elementKind atIndexPath: indexPath];
129
141
}
@@ -136,7 +148,7 @@ - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(
136
148
if ([self .delegate respondsToSelector: @selector (aopCollectionUtils:didEndDisplayingCell:forItemAtIndexPath: )]) {
137
149
[self .delegate aopCollectionUtils: self didEndDisplayingCell: cell forItemAtIndexPath: indexPath];
138
150
}
139
- kAOPRealIndexPathCode ;
151
+ kAOPUserIndexPathCode ;
140
152
if ([delegate respondsToSelector: @selector (collectionView:didEndDisplayingCell:forItemAtIndexPath: )]) {
141
153
[delegate collectionView: collectionView didEndDisplayingCell: cell forItemAtIndexPath: indexPath];
142
154
}
@@ -145,7 +157,7 @@ - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(
145
157
146
158
- (void )collectionView : (UICollectionView *)collectionView didEndDisplayingSupplementaryView : (UICollectionReusableView *)view forElementOfKind : (NSString *)elementKind atIndexPath : (NSIndexPath *)indexPath {
147
159
kAOPUICallingSaved ;
148
- kAOPRealIndexPathCode ;
160
+ kAOPUserIndexPathCode ;
149
161
if ([delegate respondsToSelector: @selector (collectionView:didEndDisplayingSupplementaryView:forElementOfKind:atIndexPath: )]) {
150
162
[delegate collectionView: collectionView didEndDisplayingSupplementaryView: view forElementOfKind: elementKind atIndexPath: indexPath];
151
163
}
@@ -154,7 +166,7 @@ - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingSupple
154
166
155
167
- (BOOL )collectionView : (UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath : (NSIndexPath *)indexPath {
156
168
kAOPUICallingSaved ;
157
- kAOPRealIndexPathCode ;
169
+ kAOPUserIndexPathCode ;
158
170
BOOL canShowMenu = YES ;
159
171
if ([delegate respondsToSelector: @selector (collectionView:shouldShowMenuForItemAtIndexPath: )]) {
160
172
canShowMenu = [delegate collectionView: collectionView shouldShowMenuForItemAtIndexPath: indexPath];
@@ -165,7 +177,7 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemA
165
177
166
178
- (BOOL )collectionView : (UICollectionView *)collectionView canPerformAction : (SEL )action forItemAtIndexPath : (NSIndexPath *)indexPath withSender : (nullable id )sender {
167
179
kAOPUICallingSaved ;
168
- kAOPRealIndexPathCode ;
180
+ kAOPUserIndexPathCode ;
169
181
BOOL canPerform = YES ;
170
182
if ([delegate respondsToSelector: @selector (collectionView:canPerformAction:forItemAtIndexPath:withSender: )]) {
171
183
canPerform = [delegate collectionView: collectionView canPerformAction: action forItemAtIndexPath: indexPath withSender: sender];
@@ -176,7 +188,7 @@ - (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)
176
188
177
189
- (void )collectionView : (UICollectionView *)collectionView performAction : (SEL )action forItemAtIndexPath : (NSIndexPath *)indexPath withSender : (nullable id )sender {
178
190
kAOPUICallingSaved ;
179
- kAOPRealIndexPathCode ;
191
+ kAOPUserIndexPathCode ;
180
192
if ([delegate respondsToSelector: @selector (collectionView:performAction:forItemAtIndexPath:withSender: )]) {
181
193
[delegate collectionView: collectionView performAction: action forItemAtIndexPath: indexPath withSender: sender];
182
194
}
@@ -185,7 +197,7 @@ - (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)act
185
197
186
198
- (BOOL )collectionView : (UICollectionView *)collectionView canFocusItemAtIndexPath : (NSIndexPath *)indexPath {
187
199
kAOPUICallingSaved ;
188
- kAOPRealIndexPathCode ;
200
+ kAOPUserIndexPathCode ;
189
201
BOOL canFocus = YES ;
190
202
if ([delegate respondsToSelector: @selector (collectionView:canFocusItemAtIndexPath: )]) {
191
203
canFocus = [delegate collectionView: collectionView canFocusItemAtIndexPath: indexPath];
@@ -208,7 +220,7 @@ - (NSIndexPath *)collectionView:(UICollectionView *)collectionView targetIndexPa
208
220
209
221
- (BOOL )collectionView : (UICollectionView *)collectionView shouldSpringLoadItemAtIndexPath : (NSIndexPath *)indexPath withContext : (id <UISpringLoadedInteractionContext>)context {
210
222
kAOPUICallingSaved ;
211
- kAOPRealIndexPathCode ;
223
+ kAOPUserIndexPathCode ;
212
224
BOOL shouldSpringLoad = YES ;
213
225
if ([delegate respondsToSelector: @selector (collectionView:shouldSpringLoadItemAtIndexPath:withContext: )]) {
214
226
shouldSpringLoad = [delegate collectionView: collectionView shouldSpringLoadItemAtIndexPath: indexPath withContext: context];
@@ -222,7 +234,7 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldSpringLoadItemAt
222
234
// water layout and flow layout
223
235
- (CGSize)collectionView : (UICollectionView *)collectionView layout : (UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath : (NSIndexPath *)indexPath {
224
236
kAOPUICallingSaved ;
225
- kAOPRealIndexPathCode ;
237
+ kAOPUserIndexPathCode ;
226
238
CGSize size = CGSizeZero;
227
239
if ([collectionViewLayout isKindOfClass: [UICollectionViewFlowLayout class ]]) {
228
240
size = ((UICollectionViewFlowLayout *)collectionViewLayout).itemSize ;
0 commit comments