Skip to content

Commit

Permalink
网络状态监测调整
Browse files Browse the repository at this point in the history
  • Loading branch information
boai committed Mar 2, 2017
1 parent 66d668a commit a13c437
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 37 deletions.
Binary file not shown.
77 changes: 40 additions & 37 deletions BANetManagerDemo/BANetManagerDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
/*!国内天气预报融合版-apikey */
//#define apikey @"82428a4618b6aa313be6914d727cb9b7"

#define BAKit_ShowAlertWithMsg(msg) [[[UIAlertView alloc] initWithTitle:@"博爱温馨提示" message:(msg) delegate:nil cancelButtonTitle:@"确 定" otherButtonTitles:nil] show];


@interface ViewController ()
{
BOOL isFinishDownload;
Expand Down Expand Up @@ -128,6 +131,39 @@ - (void)viewDidLoad {

}

#pragma mark - 网络类型判断
- (void)ba_netType
{
BAWeak;
[BANetManager ba_startNetWorkMonitoringWithBlock:^(BANetworkStatus status) {
// NSString *netType;
// switch (status) {
// case 0:
// netType = @"未知网络";
// [weakSelf alertWithMsg:netType];
// break;
// case 1:
// netType = @"没有网络";
// [weakSelf alertWithMsg:netType];
// break;
// case 2:
// netType = @"您的网络类型为:手机 3G/4G 网络";
// [weakSelf alertWithMsg:netType];
// break;
// case 3:
// netType = @"您的网络类型为:wifi 网络";
// /*! wifi 网络下请求网络:可以在父类写此方法,具体使用demo,详见:https://github.com/boai/BABaseProject */
// [weakSelf getData:nil];
// break;
//
// default:
// break;
// }
[weakSelf ba_getCurrentNetworkStatusUseDefine:YES];

}];
}

#pragma mark - 一次性网络状态判断
- (void)ba_getCurrentNetworkStatusUseDefine:(BOOL)useDefine
{
Expand All @@ -138,11 +174,11 @@ - (void)ba_getCurrentNetworkStatusUseDefine:(BOOL)useDefine
NSLog(@"有网络");
if (kIs3GOr4GNetwork)
{
NSLog(@"手机网络");
BAKit_ShowAlertWithMsg(@"手机网络");
}
else if (kIsWiFiNetwork)
{
NSLog(@"WiFi网络");
BAKit_ShowAlertWithMsg(@"WiFi网络");
}
}
}
Expand All @@ -154,49 +190,16 @@ - (void)ba_getCurrentNetworkStatusUseDefine:(BOOL)useDefine
NSLog(@"当前有网络");
if ([BANetManager ba_isWiFiNetwork])
{
NSLog(@"当前有 wifi 网络");
BAKit_ShowAlertWithMsg(@"当前有 wifi 网络");
}
if ([BANetManager ba_is3GOr4GNetwork])
{
NSLog(@"当前有 3GOr4G 网络");
BAKit_ShowAlertWithMsg(@"当前有 3GOr4G 网络");
}
}
}
}

#pragma mark - 网络类型判断
- (void)ba_netType
{
BAWeak;
[BANetManager ba_startNetWorkMonitoringWithBlock:^(BANetworkStatus status) {
// NSString *netType;
// switch (status) {
// case 0:
// netType = @"未知网络";
// [weakSelf alertWithMsg:netType];
// break;
// case 1:
// netType = @"没有网络";
// [weakSelf alertWithMsg:netType];
// break;
// case 2:
// netType = @"您的网络类型为:手机 3G/4G 网络";
// [weakSelf alertWithMsg:netType];
// break;
// case 3:
// netType = @"您的网络类型为:wifi 网络";
// /*! wifi 网络下请求网络:可以在父类写此方法,具体使用demo,详见:https://github.com/boai/BABaseProject */
// [weakSelf getData:nil];
// break;
//
// default:
// break;
// }
[weakSelf ba_getCurrentNetworkStatusUseDefine:YES];

}];
}

- (void)alertWithMsg:(NSString *)msg
{
[[[UIAlertView alloc] initWithTitle:@"温馨提示:" message:msg delegate:nil cancelButtonTitle:@"确 定" otherButtonTitles:nil, nil] show];
Expand Down

0 comments on commit a13c437

Please sign in to comment.