|
27 | 27 | */ |
28 | 28 | @interface ASCollectionView : UICollectionView |
29 | 29 |
|
| 30 | +- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout; |
| 31 | + |
30 | 32 | @property (nonatomic, weak) id<ASCollectionViewDataSource> asyncDataSource; |
31 | 33 | @property (nonatomic, weak) id<ASCollectionViewDelegate> asyncDelegate; // must not be nil |
32 | 34 |
|
33 | 35 | /** |
34 | | - * Tuning parameters for a range. |
| 36 | + * Tuning parameters for a range type. |
35 | 37 | * |
36 | | - * @param range The range to get the tuning parameters for. |
| 38 | + * @param rangeType The range type to get the tuning parameters for. |
37 | 39 | * |
38 | | - * @returns A tuning parameter value for the given range. |
| 40 | + * @returns A tuning parameter value for the given range type. |
39 | 41 | * |
40 | 42 | * Defaults to the render range having one sceenful both leading and trailing and the preload range having two |
41 | 43 | * screenfuls in both directions. |
42 | 44 | */ |
43 | 45 | - (ASRangeTuningParameters)tuningParametersForRangeType:(ASLayoutRangeType)rangeType; |
44 | 46 |
|
45 | 47 | /** |
46 | | - * Set the tuning parameters for a range. |
| 48 | + * Set the tuning parameters for a range type. |
47 | 49 | * |
48 | | - * @param tuningParameters The tuning parameters to store for a range. |
49 | | - * @param range The range to set the tuning parameters for. |
| 50 | + * @param tuningParameters The tuning parameters to store for a range type. |
| 51 | + * @param rangeType The range type to set the tuning parameters for. |
50 | 52 | */ |
51 | 53 | - (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType; |
52 | 54 |
|
53 | 55 | /** |
54 | 56 | * Initializer. |
55 | 57 | * |
| 58 | + * @param frame The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview |
| 59 | + * in which you plan to add it. This frame is passed to the superclass during initialization. |
| 60 | + * |
| 61 | + * @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. |
| 62 | + * Must not be nil. |
| 63 | + * |
| 64 | + * @param asyncDataFetchingEnabled Enable the data fetching in async mode. |
| 65 | + * |
56 | 66 | * @discussion If asyncDataFetching is enabled, the `AScollectionView` will fetch data through `collectionView:numberOfRowsInSection:` and |
57 | 67 | * `collectionView:nodeForRowAtIndexPath:` in async mode from background thread. Otherwise, the methods will be invoked synchronically |
58 | 68 | * from calling thread. |
|
70 | 80 | */ |
71 | 81 | @property (nonatomic, assign) CGFloat leadingScreensForBatching; |
72 | 82 |
|
| 83 | +/** |
| 84 | + * Perform a batch of updates asynchronously, optionally disabling all animations in the batch. This method must be called from the main thread. |
| 85 | + * The asyncDataSource must be updated to reflect the changes before the update block completes. |
| 86 | + * |
| 87 | + * @param animated NO to disable animations for this batch |
| 88 | + * @param updates The block that performs the relevant insert, delete, reload, or move operations. |
| 89 | + * @param completion A completion handler block to execute when all of the operations are finished. This block takes a single |
| 90 | + * Boolean parameter that contains the value YES if all of the related animations completed successfully or |
| 91 | + * NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. |
| 92 | + */ |
| 93 | +- (void)performBatchAnimated:(BOOL)animated updates:(void (^)())updates completion:(void (^)(BOOL))completion; |
| 94 | + |
| 95 | +/** |
| 96 | + * Perform a batch of updates asynchronously. This method must be called from the main thread. |
| 97 | + * The asyncDataSource must be updated to reflect the changes before update block completes. |
| 98 | + * |
| 99 | + * @param updates The block that performs the relevant insert, delete, reload, or move operations. |
| 100 | + * @param completion A completion handler block to execute when all of the operations are finished. This block takes a single |
| 101 | + * Boolean parameter that contains the value YES if all of the related animations completed successfully or |
| 102 | + * NO if they were interrupted. This parameter may be nil. If supplied, the block is run on the main thread. |
| 103 | + */ |
| 104 | +- (void)performBatchUpdates:(void (^)())updates completion:(void (^)(BOOL))completion; |
| 105 | + |
73 | 106 | /** |
74 | 107 | * Reload everything from scratch, destroying the working range and all cached nodes. |
75 | 108 | * |
|
87 | 120 | - (void)reloadData; |
88 | 121 |
|
89 | 122 | /** |
90 | | - * Section updating. |
| 123 | + * Inserts one or more sections. |
| 124 | + * |
| 125 | + * @param sections An index set that specifies the sections to insert. |
91 | 126 | * |
92 | | - * All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI collection |
93 | | - * view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called. |
| 127 | + * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes |
| 128 | + * before this method is called. |
94 | 129 | */ |
95 | 130 | - (void)insertSections:(NSIndexSet *)sections; |
| 131 | + |
| 132 | +/** |
| 133 | + * Deletes one or more sections. |
| 134 | + * |
| 135 | + * @param sections An index set that specifies the sections to delete. |
| 136 | + * |
| 137 | + * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes |
| 138 | + * before this method is called. |
| 139 | + */ |
96 | 140 | - (void)deleteSections:(NSIndexSet *)sections; |
| 141 | + |
| 142 | +/** |
| 143 | + * Reloads the specified sections. |
| 144 | + * |
| 145 | + * @param sections An index set that specifies the sections to reload. |
| 146 | + * |
| 147 | + * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes |
| 148 | + * before this method is called. |
| 149 | + */ |
97 | 150 | - (void)reloadSections:(NSIndexSet *)sections; |
| 151 | + |
| 152 | +/** |
| 153 | + * Moves a section to a new location. |
| 154 | + * |
| 155 | + * @param section The index of the section to move. |
| 156 | + * |
| 157 | + * @param newSection The index that is the destination of the move for the section. |
| 158 | + * |
| 159 | + * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes |
| 160 | + * before this method is called. |
| 161 | + */ |
98 | 162 | - (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection; |
99 | 163 |
|
100 | 164 | /** |
101 | | - * Items updating. |
| 165 | + * Inserts items at the locations identified by an array of index paths. |
| 166 | + * |
| 167 | + * @param indexPaths An array of NSIndexPath objects, each representing an item index and section index that together identify an item. |
102 | 168 | * |
103 | | - * All operations are asynchronous and thread safe. You can call it from background thread (it is recommendated) and the UI collection |
104 | | - * view will be updated asynchronously. The asyncDataSource must be updated to reflect the changes before these methods are called. |
| 169 | + * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes |
| 170 | + * before this method is called. |
105 | 171 | */ |
106 | 172 | - (void)insertItemsAtIndexPaths:(NSArray *)indexPaths; |
| 173 | + |
| 174 | +/** |
| 175 | + * Deletes the items specified by an array of index paths. |
| 176 | + * |
| 177 | + * @param indexPaths An array of NSIndexPath objects identifying the items to delete. |
| 178 | + * |
| 179 | + * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes |
| 180 | + * before this method is called. |
| 181 | + */ |
107 | 182 | - (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths; |
| 183 | + |
| 184 | +/** |
| 185 | + * Reloads the specified items. |
| 186 | + * |
| 187 | + * @param indexPaths An array of NSIndexPath objects identifying the items to reload. |
| 188 | + * |
| 189 | + * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes |
| 190 | + * before this method is called. |
| 191 | + */ |
108 | 192 | - (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths; |
| 193 | + |
| 194 | +/** |
| 195 | + * Moves the item at a specified location to a destination location. |
| 196 | + * |
| 197 | + * @param indexPath The index path identifying the item to move. |
| 198 | + * |
| 199 | + * @param newIndexPath The index path that is the destination of the move for the item. |
| 200 | + * |
| 201 | + * @discussion This method must be called from the main thread. The asyncDataSource must be updated to reflect the changes |
| 202 | + * before this method is called. |
| 203 | + */ |
109 | 204 | - (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath; |
110 | 205 |
|
111 | 206 | /** |
|
156 | 251 | /** |
157 | 252 | * Similar to -collectionView:cellForItemAtIndexPath:. |
158 | 253 | * |
159 | | - * @param collection The sender. |
| 254 | + * @param collectionView The sender. |
160 | 255 | * |
161 | 256 | * @param indexPath The index path of the requested node. |
162 | 257 | * |
|
168 | 263 |
|
169 | 264 | @optional |
170 | 265 |
|
| 266 | +/** |
| 267 | + * Provides the constrained size range for measuring the node at the index path. |
| 268 | + * |
| 269 | + * @param collectionView The sender. |
| 270 | + * |
| 271 | + * @param indexPath The index path of the node. |
| 272 | + * |
| 273 | + * @returns A constrained size range for layout the node at this index path. |
| 274 | + */ |
| 275 | +- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath; |
| 276 | + |
171 | 277 | /** |
172 | 278 | * Indicator to lock the data source for data fetching in async mode. |
173 | 279 | * We should not update the data source until the data source has been unlocked. Otherwise, it will incur data inconsistence or exception |
|
227 | 333 | */ |
228 | 334 | - (BOOL)shouldBatchFetchForCollectionView:(ASCollectionView *)collectionView; |
229 | 335 |
|
| 336 | +/** |
| 337 | + * Passthrough support to UICollectionViewDelegateFlowLayout sectionInset behavior. |
| 338 | + * |
| 339 | + * @param collectionView The sender. |
| 340 | + * @param collectionViewLayout The layout object requesting the information. |
| 341 | + * #param section The index number of the section whose insets are needed. |
| 342 | + * |
| 343 | + * @discussion The same rules apply as the UICollectionView implementation, but this can also be used without a UICollectionViewFlowLayout. |
| 344 | + * https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionViewDelegateFlowLayout_protocol/index.html#//apple_ref/occ/intfm/UICollectionViewDelegateFlowLayout/collectionView:layout:insetForSectionAtIndex: |
| 345 | + * |
| 346 | + */ |
| 347 | +- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section; |
| 348 | + |
230 | 349 | @end |
231 | 350 |
|
232 | 351 | @interface ASCollectionView (Deprecated) |
|
0 commit comments