Skip to content

Commit

Permalink
废弃combineReloadData 接口。 由外部自己做合并
Browse files Browse the repository at this point in the history
  • Loading branch information
ljh committed Jul 8, 2016
1 parent 152f9a0 commit 3bd7063
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 43 deletions.
1 change: 0 additions & 1 deletion Classes/Private/UITableView+IMYAOPTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


@interface _IMYAOPTableView : UITableView
- (void)aop_realReloadData;
- (void)aop_refreshDelegate;
- (void)aop_refreshDataSource;
///获取显示中的cell containType => 0:原生cell 1:插入的cell 2:全部cell
Expand Down
37 changes: 3 additions & 34 deletions Classes/Private/UITableView+IMYAOPTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -306,33 +306,9 @@ - (void)aop_layoutSubviews
- (void)aop_reloadData
{
IMYAOPTableViewUtils* aop_utils = [self aop_uiCallingUtils];
double offsetY = self.contentOffset.y;
NSString* queueKey = [NSString stringWithFormat:@"AOPReloadData_%p", self];
///只对下拉刷新 做统一reload处理
static Class AOPAsyncBlockClass;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
AOPAsyncBlockClass = [NSObject class];
if (![AOPAsyncBlockClass respondsToSelector:@selector(imy_asyncBlock:onQueue:afterSecond:forKey:)] ||
![AOPAsyncBlockClass respondsToSelector:@selector(imy_cancelBlockForKey:)] ||
![AOPAsyncBlockClass respondsToSelector:@selector(imy_hasAsyncBlockForKey:)]) {
AOPAsyncBlockClass = NULL;
}
});
if (AOPAsyncBlockClass && aop_utils.combineReloadData && offsetY < 30) {
if ([AOPAsyncBlockClass imy_hasAsyncBlockForKey:queueKey]) {
///已存在 等它自动刷新就可以了
return;
}
__weak _IMYAOPTableView* wself = self;
[AOPAsyncBlockClass imy_asyncBlock:^{
[wself aop_realReloadData];
} onQueue:dispatch_get_main_queue() afterSecond:0.2 forKey:queueKey];
}
else {
[AOPAsyncBlockClass imy_cancelBlockForKey:queueKey];
[self aop_realReloadData];
}
aop_utils.isUICalling += 1;
[super reloadData];
aop_utils.isUICalling -= 1;
}
- (void)aop_refreshDelegate
{
Expand All @@ -358,13 +334,6 @@ - (void)aop_refreshDataSource
[super setDataSource:(id)aop_utils];
uiAopUtils.isUICalling -= 1;
}
- (void)aop_realReloadData
{
IMYAOPTableViewUtils* aop_utils = [self aop_uiCallingUtils];
aop_utils.isUICalling += 1;
[super reloadData];
aop_utils.isUICalling -= 1;
}
- (void)aop_reloadSectionIndexTitles
{
IMYAOPTableViewUtils* aop_utils = [self aop_uiCallingUtils];
Expand Down
15 changes: 9 additions & 6 deletions Classes/TableUtils/IMYAOPTableViewUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
- (void)insertWithSections:(NSArray<IMYAOPTableViewInsertBody*>*)sections;
- (void)insertWithIndexPaths:(NSArray<IMYAOPTableViewInsertBody*>*)indexPaths;

/**
* 是否合并刷新, 如果开启会有个0.2的间隔来进行合并刷新 Default:NO
* 需要开启这个功能,请在podfile中加入 pod 'IMYAsyncBlock'
*/
@property (nonatomic, assign) BOOL combineReloadData;

@end


Expand All @@ -56,3 +50,12 @@
- (NSIndexSet*)tableSectionsByRealSet:(NSIndexSet*)realSet;

@end


@interface IMYAOPTableViewUtils (Deprecated_Nonfunctional)
/**
* 已废弃, 由外部自己做合并
*/
@property BOOL combineReloadData __deprecated_msg("Deprecated");
@end

11 changes: 10 additions & 1 deletion Classes/TableUtils/IMYAOPTableViewUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ - (void)setupAopClass:(Class)aopClass
[self addOverriteMethod:@selector(dequeueReusableCellWithIdentifier:) aopClass:aopClass];
[self addOverriteMethod:@selector(gestureRecognizerShouldBegin:) aopClass:aopClass];
///add real reload function
[self addOverriteMethod:@selector(aop_realReloadData) aopClass:aopClass];
[self addOverriteMethod:@selector(aop_refreshDataSource) aopClass:aopClass];
[self addOverriteMethod:@selector(aop_refreshDelegate) aopClass:aopClass];
[self addOverriteMethod:@selector(aop_containVisibleCells:) aopClass:aopClass];
Expand Down Expand Up @@ -476,4 +475,14 @@ - (BOOL)aop_installed
}
return NO;
}
@end

@implementation IMYAOPTableViewUtils (Deprecated_Nonfunctional)
- (void)setCombineReloadData:(BOOL)combineReloadData
{
}
- (BOOL)combineReloadData
{
return NO;
}
@end
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Aspect Oriented Programming For TableView,无业务入侵,无逻辑入侵,

* iOS 7+
* ARC only
* 可选:IMYAsyncBlock(https://github.com/li6185377/IMYAsyncBlock)

## 集成

Expand Down

0 comments on commit 3bd7063

Please sign in to comment.