291 lines
9.9 KiB
Objective-C
291 lines
9.9 KiB
Objective-C
//
|
||
// CameraBottomHView.m
|
||
// Ifish
|
||
//
|
||
// Created by imac on 16/11/29.
|
||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||
//
|
||
|
||
#import "CameraBottomHView.h"
|
||
#import "CameraBottomCollectionViewCell.h"
|
||
#import "IfishRecVideoViewCell.h"
|
||
static NSString *bootomCellIdentifier = @"CameraBottomCollectionViewCell";
|
||
static NSString *bootomRecCellIdentifier = @"IfishRecVideoViewCell";
|
||
#import "P2PClient.h"
|
||
|
||
@interface CameraBottomHView () <UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>
|
||
|
||
@property (nonatomic,strong) UICollectionView *collectionView;
|
||
@property (nonatomic,strong) UICollectionViewFlowLayout *flowLayout;
|
||
@property(nonatomic,strong) NSArray *dataImgArray;
|
||
@property(nonatomic,strong) NSArray *dataNameArray;
|
||
@property(nonatomic) NSIndexPath *selectIndex;
|
||
|
||
@end
|
||
|
||
@implementation CameraBottomHView
|
||
|
||
- (instancetype)initWithFrame:(CGRect)frame {
|
||
self = [super initWithFrame:frame];
|
||
if (self) {
|
||
//[self addObViserFromSelf];
|
||
[self setCollectionFrame:frame];
|
||
|
||
|
||
}
|
||
return self;
|
||
}
|
||
|
||
|
||
-(void)dealloc{
|
||
|
||
//[[NSNotificationCenter defaultCenter] removeObserver:self name:ACK_RECEIVE_REMOTE_MESSAGE object:nil];
|
||
// [[NSNotificationCenter defaultCenter] removeObserver:self name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||
if (_progressAlert) {
|
||
|
||
_progressAlert =nil;
|
||
}
|
||
}
|
||
|
||
-(void)removeObViserFromSelf{
|
||
////录制回放功能打开
|
||
// [[NSNotificationCenter defaultCenter] removeObserver:self name:ACK_RECEIVE_REMOTE_MESSAGE object:nil];
|
||
//[[NSNotificationCenter defaultCenter] removeObserver:self name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||
|
||
}
|
||
|
||
-(void)addObViserFromSelf{
|
||
|
||
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ack_receiveRemoteMessage:) name:ACK_RECEIVE_REMOTE_MESSAGE object:nil];
|
||
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveRemoteMessage:) name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||
}
|
||
|
||
-(void)setCollectionFrame:(CGRect)frame{
|
||
|
||
|
||
[self initDataArr];
|
||
self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
|
||
self.flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
||
|
||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0,0,self.frame.size.width, self.frame.size.height) collectionViewLayout:self.flowLayout];
|
||
self.collectionView.backgroundColor = [UIColor whiteColor];
|
||
self.collectionView.delegate = self;
|
||
self.collectionView.dataSource = self;
|
||
self.collectionView.showsVerticalScrollIndicator = NO;
|
||
[self addSubview:self.collectionView];
|
||
UINib *cellNib=[UINib nibWithNibName:@"CameraBottomCollectionViewCell" bundle:nil];
|
||
[self.collectionView registerNib:cellNib forCellWithReuseIdentifier:bootomCellIdentifier];
|
||
UINib *Reccell=[UINib nibWithNibName:@"IfishRecVideoViewCell" bundle:nil];
|
||
[self.collectionView registerNib:Reccell forCellWithReuseIdentifier:bootomRecCellIdentifier];
|
||
}
|
||
|
||
-(void)initDataArr
|
||
{
|
||
////录制回放功能打开
|
||
//_dataImgArray = @[LXImageWithImageName(@"devicename_iocn_screenshots.png"),LXImageWithImageName(@"devicename_iocn_gallery.png"),LXImageWithImageName(@"devicename_iocn_rec.png"),LXImageWithImageName(@"devicename_iocn_playback.png"),LXImageWithImageName(@"devicename_iocn_care.png"),LXImageWithImageName(@"devicename_iocn_look.png"),LXImageWithImageName(@"devicename_iocn_Ilookat.png"),LXImageWithImageName(@"devicename_iocn_look.png"),LXImageWithImageName(@"devicename_iocn_look.png")];
|
||
//equipment_iocn_playback
|
||
_dataImgArray = @[LXImageWithImageName(@"equipment_iocn_printscreen"),LXImageWithImageName(@"equipment_iocn_gallery"),LXImageWithImageName(@"equipment_iocn_care"),LXImageWithImageName(@"equipment_iocn_look"),LXImageWithImageName(@"equipment_iocn_mylook"),LXImageWithImageName(@"equipment_iocn_share")];
|
||
|
||
//_dataNameArray = @[@"截图",@"图库",@"录制",@"回放",@"我的看护",@"爱鱼看看",@"我的看看",@"",@""];
|
||
_dataNameArray = @[@"截图",@"图库",@"我的看护",@"爱鱼看看",@"我的看看",@"分享爱鱼奇"];
|
||
}
|
||
|
||
#pragma mark - UICollectionViewDataSource
|
||
|
||
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
|
||
{
|
||
return 1;
|
||
}
|
||
|
||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||
|
||
//return 9;
|
||
return 6;
|
||
|
||
}
|
||
#pragma mark 设置item内容
|
||
|
||
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||
{
|
||
|
||
|
||
|
||
CameraBottomCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:bootomCellIdentifier forIndexPath:indexPath];
|
||
if (!cell) {
|
||
|
||
cell = [[[NSBundle mainBundle] loadNibNamed:bootomCellIdentifier owner:self options:nil]lastObject];
|
||
}
|
||
//带回放录制
|
||
/* if (indexPath.row ==7||indexPath.row ==8)
|
||
|
||
{
|
||
cell.kindImage.hidden = YES;
|
||
|
||
}
|
||
|
||
cell.kindImage.image = _dataImgArray[indexPath.row];
|
||
cell.kindName.text = _dataNameArray[indexPath.row];
|
||
if (indexPath.row ==5) {
|
||
|
||
cell.hotImg.hidden = NO;
|
||
|
||
}
|
||
*/
|
||
|
||
cell.kindImage.image = _dataImgArray[indexPath.row];
|
||
cell.kindName.text = _dataNameArray[indexPath.row];
|
||
if (indexPath.row ==3) {
|
||
cell.hotImg.image= LXImageWithImageName(@"devicename_iocn_label");
|
||
//cell.hotImg.hidden = NO;
|
||
|
||
}else if (indexPath.row ==2){
|
||
|
||
//cell.hotImg.image= LXImageWithImageName(@"devicename_iocn_new");
|
||
}
|
||
|
||
return cell;
|
||
|
||
}
|
||
|
||
#pragma 设置item size
|
||
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||
{
|
||
|
||
//留两个像素加line分割线
|
||
CGFloat itemW =(self.frame.size.width-2)/3;
|
||
return CGSizeMake(itemW,itemW);
|
||
|
||
}
|
||
|
||
//距离上下左右的间距
|
||
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
|
||
{
|
||
|
||
return UIEdgeInsetsMake(0, 0, 0, 0);
|
||
|
||
}
|
||
|
||
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
|
||
{
|
||
//设置最小的列间距
|
||
return 1.0f;
|
||
|
||
}
|
||
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
|
||
{
|
||
//设置最小的行间距
|
||
return 1.0f;
|
||
}
|
||
|
||
#pragma mark 点击item方法
|
||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
|
||
{
|
||
|
||
/* if (indexPath.row==2) {
|
||
self.selectIndex = indexPath;
|
||
self.progressAlert = [[MBProgressHUD alloc] initWithView:self];
|
||
[self addSubview:self.progressAlert];
|
||
self.progressAlert.mode=MBProgressHUDModeCustomView;
|
||
self.progressAlert.customView = [[UIView alloc] init];
|
||
self.progressAlert.labelText = [NSString stringWithFormat:@"%@...",NSLocalizedString(@"validating", nil)];
|
||
[self.progressAlert show:YES];
|
||
[[P2PClient sharedClient]getNpcSettingsWithId:self.camera.cameraId password:self.camera.cameraPass];
|
||
|
||
}else{
|
||
|
||
if (self.cameraHViewDelegate) {
|
||
|
||
[self.cameraHViewDelegate cameraBottomHViewdidSelectAt:indexPath];
|
||
}
|
||
}
|
||
*/
|
||
|
||
if (self.cameraHViewDelegate) {
|
||
|
||
[self.cameraHViewDelegate cameraBottomHViewdidSelectAt:indexPath];
|
||
}
|
||
|
||
|
||
}
|
||
|
||
- (void)ack_receiveRemoteMessage:(NSNotification *)notification{
|
||
NSDictionary *parameter = [notification userInfo];
|
||
int key = [[parameter valueForKey:@"key"] intValue];
|
||
int result = [[parameter valueForKey:@"result"] intValue];
|
||
|
||
if (key != ACK_RET_GET_NPC_SETTINGS) {
|
||
return;
|
||
}
|
||
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
if (self.progressAlert) {
|
||
[self.progressAlert hide:YES];
|
||
}
|
||
|
||
if (result == 0)
|
||
{
|
||
|
||
//if (self.cameraHViewDelegate) {
|
||
|
||
// [self.cameraHViewDelegate cameraBottomHViewdidSelectAt:self.selectIndex];
|
||
// }
|
||
if (self.cameraHViewDelegate) {
|
||
[[P2PClient sharedClient] getSDCardInfoWithId:self.camera.cameraId password:self.camera.cameraPass];
|
||
}
|
||
//录像设置
|
||
}
|
||
|
||
else if(result==1)
|
||
{
|
||
[self makeToast:NSLocalizedString(@"device_password_error", nil)];
|
||
}
|
||
else if(result==2)
|
||
{
|
||
[self makeToast:NSLocalizedString(@"net_exception", nil)];
|
||
}
|
||
else if(result==4)
|
||
{
|
||
[self makeToast:NSLocalizedString(@"no_permission", nil)];
|
||
}
|
||
});
|
||
}
|
||
|
||
#pragma mark - receiveRemoteMessage
|
||
|
||
- (void)receiveRemoteMessage:(NSNotification *)notification
|
||
{
|
||
NSDictionary *parameter = [notification userInfo];
|
||
int key = [[parameter valueForKey:@"key"] intValue];
|
||
|
||
switch (key) {
|
||
case RET_GET_SDCARD_INFO:
|
||
{
|
||
NSInteger result = [[parameter valueForKey:@"result"] intValue];
|
||
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
if (result == 1) {
|
||
|
||
if (self.cameraHViewDelegate) {
|
||
|
||
[self.cameraHViewDelegate cameraBottomHViewdidSelectAt:self.selectIndex];
|
||
}
|
||
|
||
|
||
}else{
|
||
|
||
//sd卡不存在,
|
||
[self makeToast:NSLocalizedString(@"no_storage", nil)];
|
||
|
||
|
||
}
|
||
});
|
||
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
@end
|