mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[Batch Fetching] Add ASBatchFetchingDelegate (#281)
* Add ASBatchFetchingDelegate - In addition to checking remaining leading screens, ASBatchFetching now also calculates a remaining time and consults its delegate if needed. - The delegate can override the decision of ASBatchFetching, for example based on remaining time and average time of past batch requests. * Fix up tests * Update CHANGELOG
This commit is contained in:
@@ -21,13 +21,17 @@
|
||||
|
||||
ASDISPLAYNODE_EXTERN_C_BEGIN
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class ASBatchContext;
|
||||
@protocol ASBatchFetchingDelegate;
|
||||
|
||||
@protocol ASBatchFetchingScrollView <NSObject>
|
||||
|
||||
- (BOOL)canBatchFetch;
|
||||
- (ASBatchContext *)batchContext;
|
||||
- (CGFloat)leadingScreensForBatching;
|
||||
- (nullable id<ASBatchFetchingDelegate>)batchFetchingDelegate;
|
||||
|
||||
@end
|
||||
|
||||
@@ -39,9 +43,14 @@ ASDISPLAYNODE_EXTERN_C_BEGIN
|
||||
@param scrollDirection The current scrolling direction of the scroll view.
|
||||
@param scrollableDirections The possible scrolling directions of the scroll view.
|
||||
@param contentOffset The offset that the scrollview will scroll to.
|
||||
@param velocity The velocity of the scroll view (in points) at the moment the touch was released.
|
||||
@return Whether or not the current state should proceed with batch fetching.
|
||||
*/
|
||||
BOOL ASDisplayShouldFetchBatchForScrollView(UIScrollView<ASBatchFetchingScrollView> *scrollView, ASScrollDirection scrollDirection, ASScrollDirection scrollableDirections, CGPoint contentOffset);
|
||||
BOOL ASDisplayShouldFetchBatchForScrollView(UIScrollView<ASBatchFetchingScrollView> *scrollView,
|
||||
ASScrollDirection scrollDirection,
|
||||
ASScrollDirection scrollableDirections,
|
||||
CGPoint contentOffset,
|
||||
CGPoint velocity);
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,6 +63,8 @@ BOOL ASDisplayShouldFetchBatchForScrollView(UIScrollView<ASBatchFetchingScrollVi
|
||||
@param targetOffset The offset that the scrollview will scroll to.
|
||||
@param leadingScreens How many screens in the remaining distance will trigger batch fetching.
|
||||
@param visible Whether the view is visible or not.
|
||||
@param velocity The velocity of the scroll view (in points) at the moment the touch was released.
|
||||
@param delegate The delegate to be consulted if needed.
|
||||
@return Whether or not the current state should proceed with batch fetching.
|
||||
@discussion This method is broken into a category for unit testing purposes and should be used with the ASTableView and
|
||||
* ASCollectionView batch fetching API.
|
||||
@@ -65,6 +76,9 @@ extern BOOL ASDisplayShouldFetchBatchForContext(ASBatchContext *context,
|
||||
CGSize contentSize,
|
||||
CGPoint targetOffset,
|
||||
CGFloat leadingScreens,
|
||||
BOOL visible);
|
||||
BOOL visible,
|
||||
CGPoint velocity,
|
||||
_Nullable id<ASBatchFetchingDelegate> delegate);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
ASDISPLAYNODE_EXTERN_C_END
|
||||
|
||||
Reference in New Issue
Block a user