Skip to content

Commit

Permalink
修复倒计时时间为0时调用两次的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileZXLee committed Jan 10, 2020
1 parent 5da47c5 commit f9a2c78
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ @interface ZXCountDownCore()
@property(nonatomic,assign)long timeout;
@property(nonatomic,assign)long orgCountDownSec;
@property(nonatomic,assign)long endTimestamp;
@property(nonatomic,assign)long lastTimeout;
@property(nonatomic,strong)NSMutableDictionary *markDic;
@property(nonatomic,copy)countDownBlock resBlock;
@end
@implementation ZXCountDownCore
#pragma mark 开启倒计时
-(void)startCountDown{
if(!self.timeout)return;
if(self.timer){
if(!self.didStart){
[self refMarkDic];
Expand Down Expand Up @@ -82,11 +84,12 @@ -(void)setCountDown:(long)countDownSec mark:(NSString *)mark resBlock:(countDown
[weakSelf coreRunLoop];
}
});
dispatch_resume(self.timer);
if(disTime > 0 && !self.disableScheduleStore){
[self startCountDown];
}
}
dispatch_resume(self.timer);
if(disTime > 0 && !self.disableScheduleStore){
[self startCountDown];
}

}
}
-(void)coreRunLoop{
Expand All @@ -100,7 +103,10 @@ -(void)coreRunLoop{

}
dispatch_async(dispatch_get_main_queue(), ^{
self.resBlock(self.timeout);
if(!(self.lastTimeout == 0 && self.timeout == 0)){
self.resBlock(self.timeout);
self.lastTimeout = self.timeout;
}
});
}
#pragma mark 关闭Timer
Expand Down

0 comments on commit f9a2c78

Please sign in to comment.