Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
@@ -0,0 +1,14 @@
//
// FishSelectDeviceListViewCell.h
// Ifish
//
// Created by imac on 2017/5/5.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FishSelectDeviceListViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *deviceImg;
-(void)initCellImgsAt:(NSIndexPath *)indexPath;
@end
@@ -0,0 +1,36 @@
//
// FishSelectDeviceListViewCell.m
// Ifish
//
// Created by imac on 2017/5/5.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "FishSelectDeviceListViewCell.h"
@implementation FishSelectDeviceListViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
-(void)initCellImgsAt:(NSIndexPath *)indexPath
{
if (indexPath.row==0) {
self.deviceImg.image = [UIImage imageNamed:@"select_camera"];
}else if (indexPath.row==1){
self.deviceImg.image = [UIImage imageNamed:@"select_aquarium"];
}else if (indexPath.row ==2){
self.deviceImg.image = [UIImage imageNamed:@"select_waiting"];
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="FishSelectDeviceListViewCell" id="KGk-i7-Jjw" customClass="FishSelectDeviceListViewCell">
<rect key="frame" x="0.0" y="0.0" width="371" height="259"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="371" height="258"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="bYx-Sh-9R0">
<rect key="frame" x="0.0" y="0.0" width="371" height="259"/>
</imageView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="bYx-Sh-9R0" secondAttribute="bottom" constant="-0.5" id="MTn-E8-AeX"/>
<constraint firstAttribute="trailing" secondItem="bYx-Sh-9R0" secondAttribute="trailing" id="V13-1S-EN1"/>
<constraint firstItem="bYx-Sh-9R0" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="Zeh-7N-ZLA"/>
<constraint firstItem="bYx-Sh-9R0" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="dml-cd-hS1"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="deviceImg" destination="bYx-Sh-9R0" id="tXU-fi-Oax"/>
</connections>
<point key="canvasLocation" x="25" y="51.5"/>
</tableViewCell>
</objects>
</document>
@@ -0,0 +1,13 @@
//
// IfishBindDeviceSelectViewController.h
// Ifish
//
// Created by imac on 2017/5/5.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "BaseVIewContorller.h"
@interface IfishBindDeviceSelectViewController : BaseVIewContorller
@end
@@ -0,0 +1,271 @@
//
// IfishBindDeviceSelectViewController.m
// Ifish
//
// Created by imac on 2017/5/5.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "IfishBindDeviceSelectViewController.h"
#import "FishSelectDeviceListViewCell.h"
#import "P2PClient.h"
#import "UDPManager.h"
#import "YooseeNextConnectViewController.h"
#import "SecondConnectWifiController.h"
@interface IfishBindDeviceSelectViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *tableView;
@property(nonatomic)BOOL islogInGewell;
@end
extern BOOL isfromCameraView;
@implementation IfishBindDeviceSelectViewController
- (void)viewDidLoad {
[super viewDidLoad];
isfromCameraView = NO;
// Do any additional setup after loading the view.
[self addTitleViewWithTitle:@"选择设备"];
[self creatTab];
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self loginGewell];
if( _islogInGewell){
NSLog(@"p2pConnect success.成功,你可以操作设备了");
}else{//new added
[self loginGewell];
NSLog(@"p2pConnect failure.失败,你将不能操作设备");
return;
}
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
//CGPoint curentpoint= [self.cardScrollView contentOffsetWithIndex:[self.cardScrollView currentCard]];
//[self.cardScrollView.scrollView setContentOffset:curentpoint animated:NO];
[self loginGewell];
}
#pragma mark - loginGewell
-(void)loginGewell{
[[UDPManager sharedDefault] ScanLanDevice];
_islogInGewell = NO;
// LoginResult *loginResult = [UDManager getLoginInfo];
// NSString * P2PVerifyCode1 = @"1528438234";
// NSString * P2PVerifyCode2 = @"992805759";
// NSString *UserID = @"-2144354932";
UserModel *model=[dataContorl getUserInfo];
NSString *userIDName=[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff];
NSLog(@"%@%@%@",userIDName,model.P2PVerifyCode1,model.P2PVerifyCode2);
if ([userIDName isEqualToString:@"0"]) {
//
[self.view makeToast:@"摄像头用户名空错误码10001"];
return;
}
if ([model.P2PVerifyCode1 isEqualToString:@""]) {
[self.view makeToast:@"摄像头P2PVerifyCode1空错误码10002"];
return;
}
if ([model.P2PVerifyCode2 isEqualToString:@""]) {
[self.view makeToast:@"摄像头P2PVerifyCode2空错误码10003"];
return;
}
_islogInGewell = [[P2PClient sharedClient] p2pConnectWithId:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2];
}
-(void)creatTab{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStyleGrouped];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.showsVerticalScrollIndicator = NO;
self.tableView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.tableView];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 3;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
FishSelectDeviceListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FishSelectDeviceListViewCell"];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"FishSelectDeviceListViewCell" owner:self options:nil] lastObject];
}
[cell initCellImgsAt:indexPath];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return self.view.frame.size.width*0.698;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.1;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
Reachability *currReach = [Reachability reachabilityForLocalWiFi];
NetworkStatus status = [currReach currentReachabilityStatus];
NSLog(@"NetworkStatus%ld", (long)status);
if (status==AFNetworkReachabilityStatusReachableViaWiFi) {
//wifi环境下转跳下一界面
switch (indexPath.row) {
case 0:
{
//摄像头
NSArray * cameraArr =[[DataCenter defaultDtacenter]valueForKey:@"cameraArr"];
if ([cameraArr count]>=5) {
[self.view makeToast:@"设备已达上线限"];
return;
}
if ( self.islogInGewell) {
self.hidesBottomBarWhenPushed = YES;
YooseeNextConnectViewController *nextvc=[[YooseeNextConnectViewController alloc] init];
[self.navigationController pushViewController:nextvc animated:YES];
nextvc.conectType = 0;
}else{
UserModel *model=[dataContorl getUserInfo];
[self loginGewellWith:model];
}
}
break;
case 1:
{
//水族箱
NSArray * deviceArr =[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"];
if ([deviceArr count]>=5) {
[self.view makeToast:@"设备已达上线限"];
return;
}
self.hidesBottomBarWhenPushed = YES;
SecondConnectWifiController *wifivc=[[SecondConnectWifiController alloc]init];
[self.navigationController pushViewController:wifivc animated:YES];
}
break;
case 2:
{
//[self.view makeToast:@"敬请期待"];
}
break;
default:
break;
}
}else{
[self.view makeToast:@"请切换到WiFi环境下绑定"];
}
}
-(void)loginGewellWith:(UserModel *)model;
{
NSString *userIDName=[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff];
if ([userIDName isEqualToString:@"0"]) {
[self.view makeToast:@"暂未检测到设备"];
return;
}
if ([model.P2PVerifyCode1 isEqualToString:@""]) {
[self.view makeToast:@"暂未检测到设备"];
return;
}
if ([model.P2PVerifyCode2 isEqualToString:@""]) {
[self.view makeToast:@"暂未检测到设备"];
return;
}
self.islogInGewell = [[P2PClient sharedClient] p2pConnectWithId:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2];
//loginResult.contactId 用户ID号
NSLog(@"%@%@%@",userIDName,model.P2PVerifyCode1,model.P2PVerifyCode2);
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end