版本和自动刷新
This commit is contained in:
+32
-26
@@ -198,6 +198,7 @@
|
||||
self.heartCount=0;
|
||||
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refresh) name:UIApplicationDidBecomeActiveNotification object:nil];
|
||||
}
|
||||
|
||||
- (void)connect {
|
||||
@@ -211,34 +212,39 @@
|
||||
self.scrollview.delegate = self;
|
||||
__weak typeof (self)weakSelf=self;
|
||||
[weakSelf.scrollview addRefreshHeaderViewWithAniViewClass:[JHRefreshAmazingAniView class] beginRefresh:^{
|
||||
if (weakSelf.isRefeshing) {
|
||||
return ;
|
||||
}
|
||||
|
||||
weakSelf.isRefeshing=YES;
|
||||
if (weakSelf.isconnect) {
|
||||
searchDeviceModel*xinxiModel=[[searchDeviceModel alloc]init];
|
||||
xinxiModel.resavemacId = self.currentDevice.macAddress;
|
||||
xinxiModel.sendmacId = self.currentDevice.macAddress;
|
||||
|
||||
NSString*requestStr=xinxiModel.description;
|
||||
NSLog(@"REQUEST = %@",requestStr);
|
||||
NSData*data1=[dataContorl stringToHexData:requestStr];
|
||||
[[Socketsingleton sharedInstance].clientSocket writeData:data1 withTimeout:-1 tag:0];
|
||||
[[Socketsingleton sharedInstance].clientSocket readDataWithTimeout:-1 tag:0];
|
||||
|
||||
}else{// socket中断
|
||||
[[Socketsingleton sharedInstance] cutOffSocket];
|
||||
[weakSelf InitSocket];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[weakSelf endRefreshing];
|
||||
});
|
||||
|
||||
}
|
||||
[weakSelf refresh];
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)refresh
|
||||
{
|
||||
|
||||
if (self.isRefeshing) {
|
||||
return ;
|
||||
}
|
||||
|
||||
self.isRefeshing=YES;
|
||||
if (self.isconnect) {
|
||||
searchDeviceModel*xinxiModel=[[searchDeviceModel alloc]init];
|
||||
xinxiModel.resavemacId = self.currentDevice.macAddress;
|
||||
xinxiModel.sendmacId = self.currentDevice.macAddress;
|
||||
|
||||
NSString*requestStr=xinxiModel.description;
|
||||
NSLog(@"REQUEST = %@",requestStr);
|
||||
NSData*data1=[dataContorl stringToHexData:requestStr];
|
||||
[[Socketsingleton sharedInstance].clientSocket writeData:data1 withTimeout:-1 tag:0];
|
||||
[[Socketsingleton sharedInstance].clientSocket readDataWithTimeout:-1 tag:0];
|
||||
|
||||
}else{// socket中断
|
||||
[[Socketsingleton sharedInstance] cutOffSocket];
|
||||
[self InitSocket];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self endRefreshing];
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
-(void)endRefreshing{
|
||||
if (self.isRefeshing) {
|
||||
self.isRefeshing=NO;
|
||||
@@ -1261,7 +1267,7 @@
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user