1382 lines
54 KiB
Objective-C
1382 lines
54 KiB
Objective-C
//
|
||
// P2PPlaybackController.m
|
||
// Yoosee
|
||
//
|
||
// Created by guojunyi on 14-4-22.
|
||
// Copyright (c) 2014年 guojunyi. All rights reserved.
|
||
//
|
||
|
||
#import "P2PPlaybackController.h"
|
||
#import "AppDelegate.h"
|
||
#import "Constants.h"
|
||
//#import "MainController.h"
|
||
//#import "TopBar.h"
|
||
#import "Utils.h"
|
||
#import "Contact.h"
|
||
#import "P2PClient.h"
|
||
#import "Toast+UIView.h"
|
||
#import "P2PPlayingbackVC.h"
|
||
#import "SVPullToRefresh.h"
|
||
#import "UIScrollView+SVInfiniteScrolling.h"
|
||
|
||
#import "P2PPlayingbackVC.h"
|
||
#import "YMsgBox.h"
|
||
#import "FListManager.h"
|
||
#import "UIViewExt.h"
|
||
#import "YFonc.h"
|
||
#import "MBProgressHUD.h"
|
||
|
||
@interface P2PPlaybackController ()
|
||
{
|
||
UIView *_tfStateView;
|
||
UIImageView *_tfStateImageView;
|
||
UILabel *_tfLabel;
|
||
UILabel *_tfLabel1;
|
||
UILabel *_tfLabel2;
|
||
BOOL _isNeedHideSdState;
|
||
|
||
BOOL _msgBoxPwdErrorHadShow;
|
||
|
||
BOOL _gtACKMesg;//获取ACK回调,此用来做超时处理
|
||
BOOL _gtMsg;//获取Msg回调,此用来做超时处理
|
||
|
||
BOOL _hadShowTimeOut;
|
||
|
||
}
|
||
|
||
@end
|
||
|
||
@implementation P2PPlaybackController
|
||
|
||
|
||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
||
{
|
||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||
if (self) {
|
||
// Custom initialization
|
||
}
|
||
return self;
|
||
}
|
||
|
||
-(void)viewDidLayoutSubviews{
|
||
[super viewDidLayoutSubviews];
|
||
[self tfStateTFCardUILayout];
|
||
}
|
||
|
||
-(void)viewWillAppear:(BOOL)animated{
|
||
[super viewWillAppear:animated];
|
||
self.view.userInteractionEnabled = YES;
|
||
|
||
[[P2PClient sharedClient] setPlaybackDelegate:self];
|
||
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveRemoteMessage:) name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ack_receiveRemoteMessage:) name:ACK_RECEIVE_REMOTE_MESSAGE object:nil];
|
||
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readPlayFalse:) name:@"read_play_false" object:nil];
|
||
|
||
|
||
// MainController *mainController = [AppDelegate sharedDefault].mainController;
|
||
// if ([[AppDelegate sharedDefault]dwApContactID]) {
|
||
// mainController = [AppDelegate sharedDefault].mainController_ap;
|
||
// }
|
||
// [mainController setBottomBarHidden:YES];
|
||
|
||
|
||
|
||
}
|
||
|
||
-(void)readPlayFalse:(NSNotification*)noti{
|
||
///
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[UIView transitionWithView:self.movieView duration:0.3 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.movieView.alpha = 0.3;
|
||
}
|
||
|
||
completion:^(BOOL finished){
|
||
[self.movieView setHidden:YES];
|
||
[self.view makeToast:NSLocalizedString(@"connection_failed_please_reconnect", nil)];
|
||
}
|
||
];
|
||
});
|
||
}
|
||
|
||
-(void)viewWillDisappear:(BOOL)animated{
|
||
[super viewWillDisappear:animated];
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self name:ACK_RECEIVE_REMOTE_MESSAGE object:nil];
|
||
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"read_play_false" object:nil];
|
||
}
|
||
|
||
|
||
- (void)receiveRemoteMessage:(NSNotification *)notification{
|
||
NSDictionary *parameter = [notification userInfo];
|
||
int key = [[parameter valueForKey:@"key"] intValue];
|
||
|
||
_gtMsg=YES;
|
||
// NSLog(@"回放 收到receive消息 ,key=0x%x",key);
|
||
|
||
switch(key){
|
||
case RET_GET_SDCARD_INFO://获取有无SD卡信息
|
||
{
|
||
NSInteger result = [[parameter valueForKey:@"result"] intValue];
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
if (result == 1) { //有卡
|
||
[self.searchMaskView hide:YES];
|
||
_gtMsg=YES;
|
||
_hadShowTimeOut=YES;
|
||
|
||
self.isLoadingStorageInfo = NO;
|
||
_isNeedHideSdState = YES;
|
||
[_tfStateView setHidden:_isNeedHideSdState];
|
||
|
||
//获取是否有录像文件
|
||
if(!self.isInitSearch){
|
||
self.isInitSearch = !self.isInitSearch;
|
||
[[P2PClient sharedClient] setCurrentLabel:1];
|
||
[[P2PClient sharedClient] getPlaybackFilesWithId:self.camera.cameraId password:self.camera.cameraPass timeInterval:1];
|
||
}
|
||
[[P2PClient sharedClient] setPlaybackDelegate:self];
|
||
}else{ //无卡
|
||
[self.searchMaskView hide:YES];
|
||
_gtMsg=YES;
|
||
_hadShowTimeOut=YES;
|
||
|
||
//1.存储器不存在,隐藏表格--->return 0;
|
||
[self.tableView setUserInteractionEnabled:NO];
|
||
_isNeedHideSdState = NO;
|
||
[_tfStateView setHidden:_isNeedHideSdState];
|
||
}
|
||
});
|
||
}
|
||
break;
|
||
|
||
case RET_GET_PLAYBACK_FILES:
|
||
{
|
||
|
||
_gtMsg=YES;
|
||
_hadShowTimeOut=YES;
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[self.searchMaskView hide:YES];
|
||
|
||
});
|
||
|
||
//回放文件名称
|
||
NSArray *array = [NSArray arrayWithArray:(NSArray*)[parameter valueForKey:@"files"]];
|
||
|
||
//删除"disc1/"字符串
|
||
NSMutableArray<NSString*>* diskName = [NSMutableArray arrayWithCapacity:0];
|
||
for (NSString *element in array) {
|
||
NSMutableString * str1 = [NSMutableString stringWithString:element];
|
||
//用查找范围方式删除要删除的字符串
|
||
NSRange r1 = [str1 rangeOfString:@"disc1/"];//查找字符串
|
||
if (r1.location != NSNotFound) {
|
||
//删除查找到的字符串
|
||
[str1 deleteCharactersInRange:r1];//此只能用于可变的字符串;
|
||
}
|
||
[diskName addObject:str1];
|
||
}
|
||
|
||
//回放文件的时间记录
|
||
NSArray *times = [NSArray arrayWithArray:(NSArray*)[parameter valueForKey:@"times"]];
|
||
//回放文件的播放时长
|
||
NSArray *sizes = [NSArray arrayWithArray:(NSArray*)[parameter valueForKey:@"sizes"]];
|
||
|
||
|
||
//选择最近1天、3天、1个月或者自定义时,清空存储回放文件的数组、存储播放时长的数组
|
||
if (self.isChangePlaybackItem) {
|
||
[self.playbackFiles removeAllObjects];
|
||
[self.playbackSize removeAllObjects];
|
||
self.isChangePlaybackItem = NO;
|
||
}
|
||
|
||
//若不是上拉加载更多时,则往已清空的数组存放回放文件
|
||
//若是上拉加载更多,则往存有数据的数组末尾添加回放文件
|
||
for (NSString *file in diskName){
|
||
[self.playbackFiles addObject:file];
|
||
}
|
||
|
||
//若不是上拉加载更多时,则往数组存放回放文件的播放时长
|
||
//若是上拉加载更多,则往数组末尾添加回放文件的播放时长
|
||
for (NSString *size in sizes){
|
||
[self.playbackSize addObject:size];
|
||
}
|
||
|
||
//刷新表格
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[self.tableView reloadData];
|
||
if (self.playbackFiles.count < 1) {
|
||
[self.view makeToast:NSLocalizedString(@"no_playback_file", nil)];
|
||
}
|
||
});
|
||
|
||
|
||
self.timesData = [NSMutableArray arrayWithArray:times];
|
||
if (self.timesData.count==0) {
|
||
return;
|
||
}
|
||
|
||
//记录最近1天、3天...已显示文件里最后一个文件的时间(最早文件的时间)
|
||
//用于上拉加载时传入的结束时间
|
||
self.nextStartTime = [self.timesData lastObject];
|
||
}
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
- (void)ack_receiveRemoteMessage:(NSNotification *)notification{
|
||
|
||
_gtACKMesg=YES;
|
||
|
||
NSDictionary *parameter = [notification userInfo];
|
||
|
||
|
||
|
||
int key = [[parameter valueForKey:@"key"] intValue];
|
||
|
||
int result = [[parameter valueForKey:@"result"] intValue];
|
||
// NSLog(@"回放 收到ACK消息 ,key=0x%x,result==%ld",key,(long)result);
|
||
switch(key){
|
||
case ACK_RET_GET_PLAYBACK_FILES:
|
||
{
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
if(result==1){
|
||
_gtMsg=YES;
|
||
_hadShowTimeOut=YES;
|
||
|
||
[self.searchMaskView hide:YES];
|
||
|
||
if (!_msgBoxPwdErrorHadShow) {
|
||
_msgBoxPwdErrorHadShow=YES;
|
||
YMsgBox *yBox = [[YMsgBox alloc] init];
|
||
yBox.theTagString=@"Msg_flist_pwd_error";
|
||
yBox.yMsgTextField.secureTextEntry = YES;
|
||
[yBox addTarget:self withAction:@selector(playbackPasswordModify:) forEvent:YMsgBoxMsgTypeButtonBeClick];
|
||
yBox.yMsgTitle = [YFonc gtTextWithString:NSLocalizedString(@"password_error", nil)
|
||
withColor:[UIColor blackColor]
|
||
withFont:[UIFont systemFontOfSize:15]
|
||
withAlignment:NSTextAlignmentCenter];
|
||
yBox.yMsgTextFieldBorderColor=RGBA(62,156,254,1.0);
|
||
yBox.yMsgTextFieldBottomLineColor=[UIColor clearColor];
|
||
yBox.yMsgButtonBorderColor=RGBA(211,211,212,1.0);
|
||
UIButton *cancelBtn= [[UIButton alloc ]init];
|
||
[cancelBtn setTitleColor:UIColorFromRGB(0xa9a9a9) forState:UIControlStateNormal];
|
||
cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15];
|
||
|
||
[cancelBtn setTitle:NSLocalizedString(@"cancel",nil) forState:UIControlStateNormal];
|
||
|
||
UIButton *okBtn= [[UIButton alloc ]init];
|
||
okBtn.titleLabel.font = [UIFont systemFontOfSize:15];
|
||
[okBtn setTitle:NSLocalizedString(@"ok",nil) forState:UIControlStateNormal];
|
||
[okBtn setTitleColor:UIColorFromRGB(0x3e9cfe) forState:UIControlStateNormal];
|
||
|
||
yBox.yMsgButtons = @[cancelBtn,okBtn];
|
||
yBox.yMsgInputPlaceholder = NSLocalizedString(@"input_password",nil);
|
||
[yBox showMsgBoxInViewController:self];
|
||
// NSLog(@"文件列表 弹窗");
|
||
}
|
||
|
||
}else if(result==4){
|
||
[self.searchMaskView hide:YES];
|
||
_gtMsg=YES;
|
||
_hadShowTimeOut=YES;
|
||
[self.view makeToast:NSLocalizedString(@"no_permission", nil)];
|
||
|
||
}else if(result!=0){
|
||
|
||
[self.searchMaskView hide:YES];
|
||
|
||
_gtMsg=YES;
|
||
_hadShowTimeOut=YES;
|
||
|
||
[self.view makeToast:NSLocalizedString(@"net_exception", nil)];
|
||
}
|
||
|
||
|
||
});
|
||
DLog(@"ACK_RET_GET_PLAYBACK_FILES:%i",result);
|
||
}
|
||
break;
|
||
|
||
case ACK_RET_GET_SDCARD_INFO:
|
||
{
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
|
||
//////
|
||
|
||
if(result==1){
|
||
//密码错误
|
||
[self.searchMaskView hide:YES];
|
||
|
||
_gtMsg=YES;
|
||
_hadShowTimeOut=YES;
|
||
|
||
|
||
// NSLog(@"获取SD卡 密码错误");
|
||
if (!_msgBoxPwdErrorHadShow) {
|
||
_msgBoxPwdErrorHadShow=YES;
|
||
[self.searchMaskView hide:YES];
|
||
YMsgBox *yBox = [[YMsgBox alloc] init];
|
||
yBox.theTagString=@"Msg_sdcard_pwd_error";
|
||
yBox.yMsgTextField.secureTextEntry = YES;
|
||
[yBox addTarget:self withAction:@selector(playbackPasswordModify:) forEvent:YMsgBoxMsgTypeButtonBeClick];
|
||
yBox.yMsgTitle = [YFonc gtTextWithString:NSLocalizedString(@"password_error", nil)
|
||
withColor:[UIColor blackColor]
|
||
withFont:[UIFont systemFontOfSize:15]
|
||
withAlignment:NSTextAlignmentCenter];
|
||
yBox.yMsgTextFieldBorderColor=RGBA(62,156,254,1.0);
|
||
yBox.yMsgTextFieldBottomLineColor=[UIColor clearColor];
|
||
yBox.yMsgButtonBorderColor=RGBA(211,211,212,1.0);
|
||
UIButton *cancelBtn= [[UIButton alloc ]init];
|
||
[cancelBtn setTitleColor:UIColorFromRGB(0xa9a9a9) forState:UIControlStateNormal];
|
||
cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15];
|
||
|
||
[cancelBtn setTitle:NSLocalizedString(@"cancel",nil) forState:UIControlStateNormal];
|
||
|
||
UIButton *okBtn= [[UIButton alloc ]init];
|
||
okBtn.titleLabel.font = [UIFont systemFontOfSize:15];
|
||
[okBtn setTitle:NSLocalizedString(@"ok",nil) forState:UIControlStateNormal];
|
||
[okBtn setTitleColor:UIColorFromRGB(0x3e9cfe) forState:UIControlStateNormal];
|
||
|
||
yBox.yMsgButtons = @[cancelBtn,okBtn];
|
||
yBox.yMsgInputPlaceholder = NSLocalizedString(@"input_password",nil);
|
||
[yBox showMsgBoxInViewController:self];//不要弹窗,不然会重叠
|
||
NSLog(@"获取SD卡 弹窗");
|
||
}
|
||
|
||
}else if(result==4){
|
||
[self.searchMaskView hide:YES];
|
||
_gtMsg=YES;
|
||
_hadShowTimeOut=YES;
|
||
[self.view makeToast:NSLocalizedString(@"no_permission", nil)];
|
||
|
||
}else if(result!=0){
|
||
_gtMsg=YES;
|
||
_hadShowTimeOut=YES;
|
||
|
||
//网络异常
|
||
// NSLog(@"获取SD卡 网络异常");
|
||
[self.searchMaskView hide:YES];
|
||
[self.view makeToast:NSLocalizedString(@"net_exception", nil)];
|
||
}
|
||
});
|
||
break;
|
||
}
|
||
default:{
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[self.searchMaskView hide:YES];
|
||
// NSLog(@"ack 默认");
|
||
[self showTimeOutToast];
|
||
});
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
- (void)viewDidLoad
|
||
{
|
||
[super viewDidLoad];
|
||
|
||
_msgBoxPwdErrorHadShow=NO;
|
||
|
||
_hadShowTimeOut=NO;
|
||
|
||
_gtACKMesg=NO;
|
||
_gtMsg=NO;
|
||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)10000*NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
|
||
if (!_gtACKMesg||!_gtMsg) {
|
||
[_searchMaskView setHidden:YES];
|
||
// NSLog(@"超时显示");
|
||
[self showTimeOutToast];
|
||
}
|
||
});
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveRemoteMessage:) name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ack_receiveRemoteMessage:) name:ACK_RECEIVE_REMOTE_MESSAGE object:nil];
|
||
|
||
[[P2PClient sharedClient] setPlaybackDelegate:self];
|
||
|
||
self.isLoadingStorageInfo = YES;
|
||
[[P2PClient sharedClient] getSDCardInfoWithId:self.camera.cameraId password:self.camera.cameraPass];
|
||
|
||
[[P2PClient sharedClient] getPlaybackFilesWithId:self.camera.cameraId password:self.camera.cameraPass timeInterval:1];
|
||
|
||
[[P2PClient sharedClient] setIsClearPlaybackFilesLength:YES];//isClearPlaybackFilesLength
|
||
_isNeedHideSdState=YES;
|
||
|
||
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
|
||
|
||
self.selectedLabel = 1;
|
||
self.playbackFiles = [NSMutableArray arrayWithCapacity:0];
|
||
self.playbackSize = [NSMutableArray arrayWithCapacity:0];
|
||
|
||
[self initComponent];
|
||
|
||
[self initTfStateView];
|
||
// Do any additional setup after loading the view.
|
||
}
|
||
|
||
- (void)didReceiveMemoryWarning
|
||
{
|
||
[super didReceiveMemoryWarning];
|
||
// Dispose of any resources that can be recreated.
|
||
}
|
||
|
||
#define SEARCH_BAR_HEIGHT 36
|
||
#define TOP_INFO_BAR_HEIGHT 80
|
||
#define PLAYBACK_LIST_ITEM_HEIGHT 40
|
||
#define TOP_HEAD_MARGIN 10
|
||
#define PROGRESS_WIDTH_AND_HEIGHT 58
|
||
#define ANIM_VIEW_WIDTH_AND_HEIGHT 80
|
||
|
||
|
||
-(void)initComponent{
|
||
CGRect rect = [AppDelegate getScreenSize:YES isHorizontal:NO];
|
||
CGFloat width = rect.size.width;
|
||
CGFloat height = rect.size.height;
|
||
|
||
[self.view setBackgroundColor:XBgColor];
|
||
|
||
//TopBar *topBar = [[TopBar alloc] initWithFrame:CGRectMake(0, 0, width, NAVIGATION_BAR_HEIGHT)];
|
||
// [topBar setBackButtonHidden:NO];
|
||
// [topBar.backButton addTarget:self action:@selector(onBackPress) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
//[topBar setTitle:NSLocalizedString(@"playback",nil)];
|
||
|
||
|
||
UIView *topInfoBarView = [[UIView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT, width, TOP_INFO_BAR_HEIGHT)];
|
||
[topInfoBarView setBackgroundColor:XWhite];
|
||
UIImageView *headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(TOP_HEAD_MARGIN, TOP_HEAD_MARGIN, (TOP_INFO_BAR_HEIGHT-TOP_HEAD_MARGIN*2)*4/3, TOP_INFO_BAR_HEIGHT-TOP_HEAD_MARGIN*2)];
|
||
NSString *filePath = [Utils getHeaderFilePathWithId:self.camera.cameraId];
|
||
|
||
UIImage *headImg = [UIImage imageWithContentsOfFile:filePath];
|
||
if(headImg==nil){
|
||
headImg = [UIImage imageNamed:@"ic_header.png"];
|
||
}
|
||
headImgView.image = headImg;
|
||
|
||
[topInfoBarView addSubview:headImgView];
|
||
|
||
UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(TOP_HEAD_MARGIN+(TOP_INFO_BAR_HEIGHT-TOP_HEAD_MARGIN*2)*4/3+TOP_HEAD_MARGIN,0,width-(TOP_HEAD_MARGIN+(TOP_INFO_BAR_HEIGHT-TOP_HEAD_MARGIN*2)*4/3+TOP_HEAD_MARGIN),TOP_INFO_BAR_HEIGHT)];
|
||
|
||
nameLabel.textAlignment = NSTextAlignmentLeft;
|
||
nameLabel.textColor = XBlack;
|
||
nameLabel.backgroundColor = XBGAlpha;
|
||
[nameLabel setFont:XFontBold_18];
|
||
|
||
nameLabel.text = self.camera.showName;
|
||
[topInfoBarView addSubview:nameLabel];
|
||
|
||
[self.view addSubview:topInfoBarView];
|
||
|
||
|
||
|
||
UIView *searchBarView = [[UIView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT+TOP_INFO_BAR_HEIGHT, width, SEARCH_BAR_HEIGHT)];
|
||
[searchBarView setBackgroundColor:XWhite];
|
||
UIImageView *layarView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width/4, SEARCH_BAR_HEIGHT)];
|
||
[layarView setBackgroundColor:XBlue];
|
||
[searchBarView addSubview:layarView];
|
||
self.layerView = layarView;
|
||
|
||
|
||
for(int i=0;i<4;i++){
|
||
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(i*width/4,0,width/4,SEARCH_BAR_HEIGHT)];
|
||
button.tag = i;
|
||
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,button.frame.size.width,button.frame.size.height)];
|
||
|
||
textLabel.textAlignment = NSTextAlignmentCenter;
|
||
;
|
||
textLabel.backgroundColor = XBGAlpha;
|
||
[textLabel setFont:XFontBold_14];
|
||
textLabel.numberOfLines = 0;
|
||
if(i==0){
|
||
textLabel.textColor = XBlack;
|
||
textLabel.text = NSLocalizedString(@"recent_one_day", nil);
|
||
}else if(i==1){
|
||
textLabel.textColor = UIColorFromRGB(0x808080);
|
||
textLabel.text = NSLocalizedString(@"recent_three_day", nil);
|
||
}else if(i==2){
|
||
textLabel.textColor = UIColorFromRGB(0x808080);
|
||
textLabel.text = NSLocalizedString(@"all_playback_files", nil);
|
||
}else if(i==3){
|
||
textLabel.textColor = UIColorFromRGB(0x808080);
|
||
textLabel.text = NSLocalizedString(@"custom", nil);
|
||
}
|
||
|
||
[button addSubview:textLabel];
|
||
[button addTarget:self action:@selector(onButtonPress:) forControlEvents:UIControlEventTouchUpInside];
|
||
[searchBarView addSubview:button];
|
||
|
||
|
||
}
|
||
|
||
[self.view addSubview:searchBarView];
|
||
self.searchBarView = searchBarView;
|
||
|
||
|
||
|
||
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT+TOP_INFO_BAR_HEIGHT+SEARCH_BAR_HEIGHT, width, height-(NAVIGATION_BAR_HEIGHT+TOP_INFO_BAR_HEIGHT+SEARCH_BAR_HEIGHT)) style:UITableViewStylePlain];
|
||
|
||
tableView.delegate = self;
|
||
tableView.dataSource = self;
|
||
[tableView setBackgroundColor:XBGAlpha];
|
||
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
|
||
[self.view addSubview:tableView];
|
||
|
||
[tableView addInfiniteScrollingWithActionHandler:^{
|
||
|
||
//获取的回放文件里会包含endDate时间的文件
|
||
NSDate * endDate = [Utils dateFromString:self.nextStartTime];
|
||
|
||
if (self.selectedLabel==1) {//1 day
|
||
[self gtOneDayList];
|
||
|
||
}else if (self.selectedLabel==2){//3 days
|
||
|
||
NSDate *nowDate = [NSDate date];
|
||
//3天前
|
||
NSDate *startDate = [nowDate dateByAddingTimeInterval: -(3*24*60*60)];
|
||
|
||
[[P2PClient sharedClient] setIsLoadMorePlaybackFilesForThreeDay:YES];
|
||
|
||
[[P2PClient sharedClient] getPlaybackFilesWithIdByDate:self.camera.cameraId password:self.camera.cameraPass startDate:startDate endDate:endDate];
|
||
}else if (self.selectedLabel==3){//1 mon
|
||
|
||
NSDate *nowDate = [NSDate date];
|
||
|
||
// 从1970年开始
|
||
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970];
|
||
long long dateInterval = (long long int)timeInterval;
|
||
|
||
NSDate *startDate = [nowDate dateByAddingTimeInterval: -dateInterval];
|
||
|
||
[[P2PClient sharedClient] setIsLoadMorePlaybackFilesForOneMon:YES];
|
||
|
||
[[P2PClient sharedClient] getPlaybackFilesWithIdByDate:self.camera.cameraId password:self.camera.cameraPass startDate:startDate endDate:endDate];
|
||
}else if (self.selectedLabel==4){
|
||
|
||
[[P2PClient sharedClient] setIsLoadMorePlaybackFilesForCustom:YES];
|
||
|
||
NSDate *customStartDate = [Utils dateFromString:self.startTime];
|
||
[[P2PClient sharedClient] getPlaybackFilesWithIdByDate:self.camera.cameraId password:self.camera.cameraPass startDate:customStartDate endDate:endDate];
|
||
}//视频回放修复
|
||
|
||
self.loadCount = (unsigned long)[self.playbackFiles count];
|
||
|
||
|
||
|
||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||
sleep(1.0);
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
|
||
|
||
[self.tableView.infiniteScrollingView stopAnimating];
|
||
|
||
if (self.loadCount == (unsigned long)[self.playbackFiles count]) {
|
||
[self.searchMaskView hide:YES];
|
||
[self.view makeToast:NSLocalizedString(@"no_more_record", nil)];
|
||
}
|
||
|
||
});
|
||
});
|
||
|
||
}];
|
||
|
||
self.tableView = tableView;
|
||
|
||
UIView *searchMaskView = [[UIView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT, self.view.frame.size.width, self.view.frame.size.height-NAVIGATION_BAR_HEIGHT)];
|
||
// [searchMaskView setBackgroundColor:XBlack_128];
|
||
// UIActivityIndicatorView *progress = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
|
||
// progress.frame = CGRectMake((searchMaskView.frame.size.width-PROGRESS_WIDTH_AND_HEIGHT)/2, (searchMaskView.frame.size.height-PROGRESS_WIDTH_AND_HEIGHT)/2, PROGRESS_WIDTH_AND_HEIGHT, PROGRESS_WIDTH_AND_HEIGHT);
|
||
// [progress startAnimating];
|
||
// [searchMaskView addSubview:progress];
|
||
// [progress release];
|
||
// [searchMaskView setHidden:NO];
|
||
// [self.view addSubview:searchMaskView];
|
||
// self.searchMaskView = searchMaskView;
|
||
|
||
self.searchMaskView = [[MBProgressHUD alloc] initWithView:searchMaskView] ;
|
||
[self.view addSubview:self.searchMaskView];
|
||
self.searchMaskView.dimBackground = YES;
|
||
[self.searchMaskView show:YES];
|
||
|
||
|
||
UIView *movieView = [[UIView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT, self.view.frame.size.width, self.view.frame.size.height-NAVIGATION_BAR_HEIGHT)];
|
||
[movieView setBackgroundColor:XBlack_128];
|
||
UIImageView *animView = [[UIImageView alloc] initWithFrame:CGRectMake((movieView.frame.size.width-ANIM_VIEW_WIDTH_AND_HEIGHT)/2, (movieView.frame.size.height-ANIM_VIEW_WIDTH_AND_HEIGHT)/2, ANIM_VIEW_WIDTH_AND_HEIGHT, ANIM_VIEW_WIDTH_AND_HEIGHT)];
|
||
|
||
NSArray *imagesArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"movie1.png"],[UIImage imageNamed:@"movie2.png"],[UIImage imageNamed:@"movie3.png"],nil];
|
||
|
||
animView.animationImages = imagesArray;
|
||
animView.animationDuration = ((CGFloat)[imagesArray count])*100.0f/1000.0f;
|
||
animView.animationRepeatCount = 0;
|
||
[animView startAnimating];
|
||
|
||
[movieView addSubview:animView];
|
||
|
||
[movieView setHidden:YES];
|
||
[self.view addSubview:movieView];
|
||
self.movieView = movieView;
|
||
|
||
|
||
|
||
[self initCustomView];
|
||
|
||
//使Tabbar保证在最顶层
|
||
//[self.view addSubview:topBar];
|
||
|
||
}
|
||
-(void)gtOneDayList{
|
||
NSDate * endDate = [Utils dateFromString:self.nextStartTime];
|
||
|
||
NSDate *nowDate = [NSDate date];
|
||
//1天前
|
||
NSDate *startDate = [nowDate dateByAddingTimeInterval: -(24*60*60)];
|
||
|
||
[[P2PClient sharedClient] setIsLoadMorePlaybackFilesForOneDay:YES];
|
||
|
||
[[P2PClient sharedClient] getPlaybackFilesWithIdByDate:self.camera.cameraId password:self.camera.cameraPass startDate:startDate endDate:endDate];
|
||
}
|
||
|
||
|
||
-(void)initTfStateView
|
||
{
|
||
_tfStateView = [[UIView alloc] init];
|
||
_tfStateView.backgroundColor=[UIColor clearColor];
|
||
[self.view addSubview:_tfStateView];
|
||
[_tfStateView setHidden:YES];
|
||
|
||
|
||
_tfStateImageView=[[UIImageView alloc] init];
|
||
_tfStateImageView.backgroundColor=[UIColor clearColor];
|
||
[_tfStateImageView setImage:[UIImage imageNamed:@"playback_no_tfcard.png"]];
|
||
[_tfStateView addSubview:_tfStateImageView];
|
||
|
||
|
||
|
||
_tfLabel = [[UILabel alloc] init];
|
||
_tfLabel.backgroundColor = [UIColor clearColor];
|
||
_tfLabel.font = [UIFont systemFontOfSize:30.0/2.0];
|
||
_tfLabel.textColor = UIColorFromRGB(0x5586f6);
|
||
_tfLabel.text = NSLocalizedString(@"no_storage_card_inserted_into_your_camera", nil);
|
||
_tfLabel.textAlignment = NSTextAlignmentCenter;
|
||
[_tfStateView addSubview:_tfLabel];
|
||
|
||
|
||
|
||
_tfLabel1 = [[UILabel alloc] init];
|
||
_tfLabel1.backgroundColor = [UIColor clearColor];
|
||
_tfLabel1.font = [UIFont systemFontOfSize:24/2.0];
|
||
_tfLabel1.textColor = UIColorFromRGB(0xa9a9a9);
|
||
_tfLabel1.text = NSLocalizedString(@"storage_card_text", nil);
|
||
_tfLabel1.numberOfLines = 0;
|
||
_tfLabel1.textAlignment = NSTextAlignmentCenter;
|
||
[_tfStateView addSubview:_tfLabel1];
|
||
|
||
}
|
||
|
||
#pragma mark 布局
|
||
-(void)tfStateTFCardUILayout{
|
||
|
||
//录像状态
|
||
CGFloat TempW=self.view.width / 1.3;
|
||
CGFloat TempH=460.0/2.0;
|
||
CGFloat TempX=(self.view.width - TempW) / 2.0;
|
||
CGFloat TempY=NAVIGATION_BAR_HEIGHT+TOP_INFO_BAR_HEIGHT + SEARCH_BAR_HEIGHT + 164.0/2.0;
|
||
CGRect newRect=CGRectMake(TempX, TempY, TempW, TempH);
|
||
// _tfStateView.backgroundColor = [UIColor redColor];
|
||
_tfStateView.frame=newRect;
|
||
|
||
//REC文本控件
|
||
TempW=252.0/2.0;
|
||
TempH=162.0/2.0;
|
||
TempX=(_tfStateView.width - TempW)/2.0;
|
||
TempY=0.0;
|
||
newRect=CGRectMake(TempX, TempY, TempW, TempH);
|
||
_tfStateImageView.frame=newRect;
|
||
|
||
TempW=_tfStateView.width;
|
||
TempH=16.0;
|
||
TempX=0.0;
|
||
TempY=_tfStateImageView.bottom + 33.0/2.0;
|
||
newRect=CGRectMake(TempX, TempY, TempW, TempH);
|
||
_tfLabel.frame=newRect;
|
||
|
||
TempW=_tfStateView.width;
|
||
TempH=[YFonc gtTextCGSize:_tfLabel1.text withTextMaxWidth:TempW withFont:_tfLabel1.font].height;
|
||
// TempH=_tfStateView.height - _tfLabel.bottom;
|
||
TempX=0.0;
|
||
TempY=_tfLabel.bottom + 31.0/2.0;
|
||
newRect=CGRectMake(TempX, TempY, TempW, TempH);
|
||
// _tfLabel1.backgroundColor = [UIColor orangeColor];
|
||
_tfLabel1.frame=newRect;
|
||
}
|
||
|
||
|
||
#define CUSTOM_VIEW_HEIGHT 338
|
||
#define CUSTOM_VIEW_RIGHT_BTN_WIDTH_AND_HEIGHT 38
|
||
#define CUSTOM_VIEW_INPUT_VIEW_HEIGHT 100
|
||
#define CUSTOM_VIEW_INPUT_VIEW_ITEM_LEFT_LABEL_WIDTH 75
|
||
-(void)initCustomView{
|
||
CGRect rect = [AppDelegate getScreenSize:YES isHorizontal:NO];
|
||
CGFloat width = rect.size.width;
|
||
CGFloat height = rect.size.height;
|
||
|
||
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, height, width, CUSTOM_VIEW_HEIGHT)];
|
||
[customView setBackgroundColor:XWhite];
|
||
|
||
//查询按钮
|
||
UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
[searchBtn addTarget:self action:@selector(onCustomSearch:) forControlEvents:UIControlEventTouchUpInside];
|
||
[searchBtn setBackgroundColor:[UIColor grayColor]];
|
||
[searchBtn setBackgroundImage:[UIImage imageNamed:@"bg_normal_cell_p.png"] forState:UIControlStateHighlighted];
|
||
searchBtn.frame = CGRectMake(0, 0, customView.frame.size.width, CUSTOM_VIEW_RIGHT_BTN_WIDTH_AND_HEIGHT);
|
||
//查询文本
|
||
UILabel *searchLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, searchBtn.frame.size.width, searchBtn.frame.size.height)];
|
||
searchLabel.textAlignment = NSTextAlignmentCenter;
|
||
searchLabel.textColor = XWhite;
|
||
searchLabel.font = XFontBold_16;
|
||
searchLabel.backgroundColor = XBGAlpha;
|
||
searchLabel.text = NSLocalizedString(@"search", nil);
|
||
[searchBtn addSubview:searchLabel];
|
||
|
||
|
||
// UIImageView *sep = [[UIImageView alloc] initWithFrame:CGRectMake(searchBtn.frame.size.width, 0, 1, searchBtn.frame.size.height)];
|
||
// [sep setBackgroundColor:XBlack];
|
||
// [customView addSubview: sep];
|
||
// [sep release];
|
||
|
||
// UIButton *hideBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
// [hideBtn setBackgroundImage:[UIImage imageNamed:@"bg_normal_cell_p.png"] forState:UIControlStateHighlighted];
|
||
// hideBtn.frame = CGRectMake(customView.frame.size.width-CUSTOM_VIEW_RIGHT_BTN_WIDTH_AND_HEIGHT, 0, CUSTOM_VIEW_RIGHT_BTN_WIDTH_AND_HEIGHT, CUSTOM_VIEW_RIGHT_BTN_WIDTH_AND_HEIGHT);
|
||
|
||
// [customView addSubview:hideBtn];
|
||
[customView addSubview:searchBtn];
|
||
|
||
|
||
//
|
||
UIView *inputView = [[UIView alloc] initWithFrame:CGRectMake(0, CUSTOM_VIEW_RIGHT_BTN_WIDTH_AND_HEIGHT, customView.frame.size.width, CUSTOM_VIEW_INPUT_VIEW_HEIGHT)];
|
||
[inputView setBackgroundColor:XWhite];
|
||
//查询开始时间按钮
|
||
UIButton *startTime = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, inputView.frame.size.width-20, (inputView.frame.size.height-30)/2)];
|
||
startTime.tag = 0;
|
||
startTime.layer.cornerRadius = 2;
|
||
startTime.layer.borderWidth = 1;
|
||
startTime.layer.borderColor = [XWhite CGColor];
|
||
startTime.layer.masksToBounds = YES;
|
||
startTime.backgroundColor = UIColorFromRGB(0xcccccc);
|
||
[startTime.layer setShadowOffset:CGSizeMake(0, 0)];
|
||
[startTime.layer setShadowColor:[XBlue CGColor]];
|
||
[startTime.layer setShadowOpacity:1.0];
|
||
[startTime setClipsToBounds:NO];
|
||
self.startTimeBtn = startTime;
|
||
[startTime addTarget:self action:@selector(changeTimeBtnShadow:) forControlEvents:UIControlEventTouchUpInside];
|
||
//文本
|
||
CGFloat startLeftLabel_w = [Utils getStringWidthWithString:NSLocalizedString(@"start_time", nil) font:XFontBold_16 maxWidth:1000]+5.0;
|
||
UILabel *startLeftLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, startLeftLabel_w, startTime.frame.size.height)];
|
||
startLeftLabel.textAlignment = NSTextAlignmentRight;
|
||
startLeftLabel.textColor = XBlue;
|
||
startLeftLabel.font = XFontBold_16;
|
||
startLeftLabel.backgroundColor = XBGAlpha;
|
||
startLeftLabel.text = NSLocalizedString(@"start_time", nil);
|
||
[startTime addSubview:startLeftLabel];
|
||
|
||
//文本
|
||
UILabel *startRightLabel = [[UILabel alloc] initWithFrame:CGRectMake(startLeftLabel_w, 0, startTime.frame.size.width-startLeftLabel_w, startTime.frame.size.height)];
|
||
startRightLabel.textAlignment = NSTextAlignmentLeft;
|
||
startRightLabel.textColor = XBlue;
|
||
startRightLabel.font = XFontBold_16;
|
||
startRightLabel.backgroundColor = XBGAlpha;
|
||
startRightLabel.text = @"";
|
||
[startTime addSubview:startRightLabel];
|
||
self.startTimeLabel = startRightLabel;
|
||
|
||
|
||
[inputView addSubview:startTime];
|
||
|
||
//查询结束时间按钮
|
||
UIButton *endTime = [[UIButton alloc] initWithFrame:CGRectMake(10, 10+(inputView.frame.size.height-30)/2+10, inputView.frame.size.width-20, (inputView.frame.size.height-30)/2)];
|
||
endTime.tag = 1;
|
||
endTime.layer.cornerRadius = 2;
|
||
endTime.layer.borderWidth = 1;
|
||
endTime.layer.borderColor = [XWhite CGColor];
|
||
endTime.layer.masksToBounds = YES;
|
||
endTime.backgroundColor = UIColorFromRGB(0xcccccc);
|
||
[endTime.layer setShadowOffset:CGSizeMake(1, 1)];
|
||
[endTime.layer setShadowColor:[XBGAlpha CGColor]];
|
||
[endTime.layer setShadowOpacity:1.0];
|
||
[endTime setClipsToBounds:NO];
|
||
self.endTimeBtn = endTime;
|
||
[endTime addTarget:self action:@selector(changeTimeBtnShadow:) forControlEvents:UIControlEventTouchUpInside];
|
||
//文本
|
||
CGFloat endLeftLabel_w = [Utils getStringWidthWithString:NSLocalizedString(@"end_time", nil) font:XFontBold_16 maxWidth:1000]+5.0;
|
||
UILabel *endLeftLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, endLeftLabel_w, endTime.frame.size.height)];
|
||
endLeftLabel.textAlignment = NSTextAlignmentRight;
|
||
endLeftLabel.textColor = XBlue;
|
||
endLeftLabel.font = XFontBold_16;
|
||
endLeftLabel.backgroundColor = XBGAlpha;
|
||
endLeftLabel.text = NSLocalizedString(@"end_time", nil);
|
||
[endTime addSubview:endLeftLabel];
|
||
|
||
//文本
|
||
UILabel *endRightLabel = [[UILabel alloc] initWithFrame:CGRectMake(endLeftLabel_w, 0, endTime.frame.size.width-endLeftLabel_w, endTime.frame.size.height)];
|
||
endRightLabel.textAlignment = NSTextAlignmentLeft;
|
||
endRightLabel.textColor = XBlue;
|
||
endRightLabel.font = XFontBold_16;
|
||
endRightLabel.backgroundColor = XBGAlpha;
|
||
endRightLabel.text = @"";
|
||
[endTime addSubview:endRightLabel];
|
||
self.endTimeLabel = endRightLabel;
|
||
|
||
|
||
|
||
[inputView addSubview:endTime];
|
||
[customView addSubview: inputView];
|
||
|
||
|
||
[self.view addSubview:customView];
|
||
self.customView = customView;
|
||
|
||
|
||
|
||
|
||
//时间选择器
|
||
// UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, CUSTOM_VIEW_RIGHT_BTN_WIDTH_AND_HEIGHT+CUSTOM_VIEW_INPUT_VIEW_HEIGHT, customView.frame.size.width, CUSTOM_VIEW_HEIGHT-CUSTOM_VIEW_RIGHT_BTN_WIDTH_AND_HEIGHT-CUSTOM_VIEW_INPUT_VIEW_HEIGHT)];
|
||
//
|
||
// [datePicker setDatePickerMode:UIDatePickerModeDateAndTime];
|
||
// [datePicker setDate:[NSDate date] animated:NO];
|
||
// NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];
|
||
// if ([language isEqualToString:@"zh-Hans"]) {
|
||
// NSLocale* locale=[[NSLocale alloc]initWithLocaleIdentifier:@"zh-Hans"];
|
||
// [datePicker setLocale:locale];
|
||
// }else if ([language isEqualToString:@"en"]){
|
||
// NSLocale* locale=[[NSLocale alloc]initWithLocaleIdentifier:@"en"];
|
||
// [datePicker setLocale:locale];
|
||
// }
|
||
// [datePicker setMinimumDate:[Utils dateFromString:[NSString stringWithFormat:@"2013-07-01 00:00"]]];
|
||
// [datePicker setMaximumDate:[Utils dateFromString:[NSString stringWithFormat:@"2035-12-31 23:59"]]];
|
||
// [datePicker addTarget:self action:@selector(onDatePickChange:) forControlEvents:UIControlEventValueChanged];
|
||
//
|
||
// [customView addSubview:datePicker];
|
||
// [datePicker release];
|
||
|
||
CGFloat dwItemHeight = 30;
|
||
CyclePickerView* cycleview = [[CyclePickerView alloc] initWithFrame:CGRectMake(0,50+CUSTOM_VIEW_INPUT_VIEW_HEIGHT+dwItemHeight, width, dwItemHeight*5)];
|
||
cycleview.delegate = self;
|
||
cycleview.datasource = self;
|
||
[cycleview reloadScroll];
|
||
[self.customView addSubview:cycleview];
|
||
self.cycleview = cycleview;
|
||
|
||
|
||
NSDateComponents *dateComponents = [Utils getNowDateComponents];
|
||
int year = (int)[dateComponents year];
|
||
int month = (int)[dateComponents month];
|
||
int day = (int)[dateComponents day];
|
||
int hour = (int)[dateComponents hour];
|
||
int minute = (int)[dateComponents minute];
|
||
[self.cycleview selectCell:year-2010 inScroll:0];
|
||
[self.cycleview selectCell:month-1 inScroll:1];
|
||
[self.cycleview selectCell:day-1 inScroll:2];
|
||
[self.cycleview selectCell:hour inScroll:3];
|
||
[self.cycleview selectCell:minute inScroll:4];
|
||
|
||
//年月日时分文本
|
||
UIView* headlabelview = [[UIView alloc] initWithFrame:CGRectMake(0,50+CUSTOM_VIEW_INPUT_VIEW_HEIGHT, width, dwItemHeight)];
|
||
NSArray * arr = @[NSLocalizedString(@"year", nil),NSLocalizedString(@"month", nil),NSLocalizedString(@"day", nil),NSLocalizedString(@"hour", nil),NSLocalizedString(@"minute", nil)];
|
||
CGFloat noworigin = 0.0;
|
||
for (NSInteger i = 0; i<5; i++)
|
||
{
|
||
UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(noworigin*headlabelview.frame.size.width, 0, [self.cycleview.scrollWidthProportion[i] floatValue]*headlabelview.frame.size.width, headlabelview.frame.size.height)];
|
||
label.text = arr[i];
|
||
label.textAlignment = NSTextAlignmentCenter;
|
||
[headlabelview addSubview:label];
|
||
|
||
noworigin+=[self.cycleview.scrollWidthProportion[i] floatValue];
|
||
}
|
||
[self.customView addSubview:headlabelview];
|
||
}
|
||
|
||
#pragma mark - CyclePickerViewDelegate
|
||
- (void)CyclePickerViewDidChangeValue:(NSArray *) valuearr{
|
||
|
||
NSString *time = [Utils getDeviceTimeByIntValue:[valuearr[0] integerValue]
|
||
month:[valuearr[1] integerValue]
|
||
day:[valuearr[2] integerValue]
|
||
hour:[valuearr[3] integerValue]
|
||
minute:[valuearr[4] integerValue]];
|
||
|
||
switch(self.selectedTimeTag){
|
||
case 0:
|
||
{
|
||
self.startTimeLabel.text = time;
|
||
}
|
||
break;
|
||
case 1:
|
||
{
|
||
self.endTimeLabel.text = time;
|
||
}
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
//指定每一列的滚轮上的Cell的个数
|
||
- (NSUInteger)numberOfCellsInScroll:(NSUInteger)scroll{
|
||
switch (scroll) {
|
||
case 0:
|
||
return 27;
|
||
break;
|
||
case 1:
|
||
return 12;
|
||
break;
|
||
case 2:
|
||
return 31;
|
||
break;
|
||
case 3:
|
||
return 24;
|
||
break;
|
||
case 4:
|
||
return 60;
|
||
break;
|
||
default:
|
||
return 10;
|
||
break;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
//指定每一列滚轮所占整体宽度的比例,以:分隔
|
||
- (NSString *)scrollWidthProportion{
|
||
return @"1:1:1:1:1";
|
||
}
|
||
//指定每一列的滚轮上的Cell的初始值,以:分隔
|
||
- (NSString *)valueOfCellsInScroll{
|
||
return @"2010:1:1:0:0";
|
||
}
|
||
|
||
-(void)onCustomSearch:(UIButton*)button{
|
||
NSString *startTime = self.startTimeLabel.text;
|
||
NSString *endTime = self.endTimeLabel.text;
|
||
|
||
self.startTime = startTime;
|
||
self.endTime = endTime;
|
||
|
||
if(!startTime||!(startTime.length>0)){
|
||
[self.searchMaskView hide:YES];
|
||
[self.view makeToast:NSLocalizedString(@"unselected_start_time", nil)];
|
||
return;
|
||
}
|
||
|
||
if(!endTime||!(endTime.length>0)){
|
||
[self.searchMaskView hide:YES];
|
||
[self.view makeToast:NSLocalizedString(@"unselected_end_time", nil)];
|
||
return;
|
||
}
|
||
|
||
NSDate *startDate = [Utils dateFromString:startTime];
|
||
NSDate *endDate = [Utils dateFromString:endTime];
|
||
if([startDate timeIntervalSince1970]>=[endDate timeIntervalSince1970]){
|
||
[self.searchMaskView hide:YES];
|
||
[self.view makeToast:NSLocalizedString(@"start_time_must_before_end_time", nil)];
|
||
return;
|
||
}
|
||
|
||
self.searchMaskView.dimBackground = YES;
|
||
[self.searchMaskView show:YES];
|
||
|
||
|
||
|
||
if(self.isShowCustomView){
|
||
self.isShowCustomView = !self.isShowCustomView;
|
||
[UIView transitionWithView:self.customView duration:0.2 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.customView.transform = CGAffineTransformMakeTranslation(0,0);
|
||
}
|
||
|
||
completion:^(BOOL isFinish){
|
||
|
||
}
|
||
];
|
||
}
|
||
|
||
[[P2PClient sharedClient] getPlaybackFilesWithIdByDate:self.camera.cameraId password:self.camera.cameraPass startDate:startDate endDate:endDate];
|
||
}
|
||
|
||
-(void)changeTimeBtnShadow:(UIButton*)button{
|
||
self.selectedTimeTag = button.tag;
|
||
switch(button.tag){
|
||
case 0:
|
||
{
|
||
[self.startTimeBtn.layer setShadowColor:[XBlue CGColor]];
|
||
[self.endTimeBtn.layer setShadowColor:[XBGAlpha CGColor]];
|
||
|
||
}
|
||
break;
|
||
case 1:
|
||
{
|
||
[self.startTimeBtn.layer setShadowColor:[XBGAlpha CGColor]];
|
||
[self.endTimeBtn.layer setShadowColor:[XBlue CGColor]];
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
-(void)onDatePickChange:(UIDatePicker*)datePick{
|
||
NSString *dateString = [Utils stringFromDate:[datePick date]];
|
||
switch(self.selectedTimeTag){
|
||
case 0:
|
||
{
|
||
self.startTimeLabel.text = dateString;
|
||
}
|
||
break;
|
||
case 1:
|
||
{
|
||
self.endTimeLabel.text = dateString;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||
return [self.playbackFiles count];
|
||
}
|
||
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
return PLAYBACK_LIST_ITEM_HEIGHT;
|
||
}
|
||
|
||
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
static NSString *identifier = @"PlaybackCell";
|
||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
|
||
if(cell==nil){
|
||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
|
||
}
|
||
|
||
UIImage *backImg = [UIImage imageNamed:@"bg_normal_cell.png"];
|
||
UIImage *backImg_p = [UIImage imageNamed:@"bg_normal_cell_p.png"];
|
||
UIImageView *backImageView = [[UIImageView alloc] init];
|
||
UIImageView *backImageView_p = [[UIImageView alloc] init];
|
||
|
||
backImg = [backImg stretchableImageWithLeftCapWidth:backImg.size.width*0.5 topCapHeight:backImg.size.height*0.5];
|
||
backImageView.image = backImg;
|
||
[cell setBackgroundView:backImageView];
|
||
|
||
backImg_p = [backImg_p stretchableImageWithLeftCapWidth:backImg_p.size.width*0.5 topCapHeight:backImg_p.size.height*0.5];
|
||
backImageView_p.image = backImg_p;
|
||
[cell setSelectedBackgroundView:backImageView_p];
|
||
|
||
|
||
|
||
|
||
NSString* name = [self.playbackFiles objectAtIndex:indexPath.row];
|
||
|
||
int iSize = 0;
|
||
if ([self.playbackFiles count] == [self.playbackSize count]) //查询到了文件长度
|
||
{
|
||
NSNumber* number = [self.playbackSize objectAtIndex:indexPath.row];
|
||
iSize = [number intValue];
|
||
}
|
||
if (iSize != 0) {//支持返回播放时长
|
||
cell.textLabel.text = [NSString stringWithFormat:@"%@ (%02d:%02d)", name, iSize/60, iSize%60];
|
||
}
|
||
else
|
||
{
|
||
cell.textLabel.text = [NSString stringWithFormat:@"%@ (%02d:%02d)", name, iSize/60, iSize%60];
|
||
}
|
||
cell.textLabel.font = CURRENT_VERSION >= 9.0 ? XFontBold_14 : XFontBold_16;
|
||
|
||
|
||
return cell;
|
||
}
|
||
|
||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||
|
||
[self.movieView setHidden:NO];
|
||
self.movieView.alpha = 0.3;
|
||
|
||
[UIView transitionWithView:self.movieView duration:0.3 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.movieView.alpha = 1.0;
|
||
}
|
||
|
||
completion:^(BOOL finished){
|
||
|
||
}
|
||
];
|
||
[[P2PClient sharedClient] p2pPlaybackCallWithId:self.camera.cameraId password:self.camera.cameraPass index:indexPath.row];
|
||
}
|
||
|
||
-(void)updateLabelColor:(NSInteger)index{
|
||
for(UIView *view in self.searchBarView.subviews){
|
||
if([view isKindOfClass:[UIButton class]]){
|
||
UILabel *label = [view.subviews objectAtIndex:0];
|
||
|
||
if(view.tag==index){
|
||
label.textColor = XBlack;
|
||
}else{
|
||
label.textColor = UIColorFromRGB(0x808080);
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
-(void)onButtonPress:(id)sender{
|
||
UIButton *button = (UIButton*)sender;
|
||
BOOL isCustom = NO;
|
||
self.isChangePlaybackItem = YES;//视频回放修复
|
||
[[P2PClient sharedClient] setIsClearPlaybackFilesLength:YES];//视频回放修复
|
||
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[self.searchMaskView hide:YES];
|
||
});
|
||
|
||
switch(button.tag){
|
||
case 0:
|
||
{
|
||
[_tfStateView setHidden:_isNeedHideSdState];
|
||
self.selectedLabel = 1;
|
||
[[P2PClient sharedClient] setCurrentLabel:1];
|
||
|
||
[self updateLabelColor:0];
|
||
if (_isNeedHideSdState) {
|
||
[[P2PClient sharedClient] getPlaybackFilesWithId:self.camera.cameraId password:self.camera.cameraPass timeInterval:1];
|
||
}
|
||
}
|
||
break;
|
||
case 1:
|
||
{
|
||
[_tfStateView setHidden:_isNeedHideSdState];
|
||
self.selectedLabel = 2;
|
||
[[P2PClient sharedClient] setCurrentLabel:2];
|
||
|
||
[self updateLabelColor:1];
|
||
if (_isNeedHideSdState) {
|
||
[[P2PClient sharedClient] getPlaybackFilesWithId:self.camera.cameraId password:self.camera.cameraPass timeInterval:3];
|
||
}
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
[_tfStateView setHidden:_isNeedHideSdState];
|
||
self.selectedLabel = 3;
|
||
[[P2PClient sharedClient] setCurrentLabel:3];
|
||
// 从1970年开始
|
||
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970];
|
||
long long dateInterval = (long long int)timeInterval;
|
||
[self updateLabelColor:2];
|
||
if (_isNeedHideSdState) {
|
||
[[P2PClient sharedClient] getPlaybackFilesWithId:self.camera.cameraId password:self.camera.cameraPass timeInterval:dateInterval/(24*60*60)];
|
||
}
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
if (_isNeedHideSdState) {
|
||
[_tfStateView setHidden:YES];
|
||
isCustom = YES;
|
||
|
||
}
|
||
self.selectedLabel = 4;
|
||
[[P2PClient sharedClient] setCurrentLabel:4];
|
||
|
||
[self updateLabelColor:3];
|
||
|
||
|
||
}
|
||
break;
|
||
}
|
||
|
||
|
||
[UIView transitionWithView:self.layerView duration:0.2 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.layerView.frame = CGRectMake(button.tag*button.frame.size.width, self.layerView.frame.origin.y, self.layerView.frame.size.width, self.layerView.frame.size.height);
|
||
}
|
||
|
||
completion:^(BOOL finished){
|
||
|
||
}
|
||
];
|
||
|
||
if(!isCustom){
|
||
self.searchMaskView.dimBackground = YES;
|
||
[self.searchMaskView show:YES];
|
||
self.searchMaskView.alpha = 1.0;
|
||
|
||
if(self.isShowCustomView){
|
||
self.isShowCustomView = !self.isShowCustomView;
|
||
[UIView transitionWithView:self.customView duration:0.2 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.customView.transform = CGAffineTransformMakeTranslation(0,0);
|
||
}
|
||
|
||
completion:^(BOOL isFinish){
|
||
|
||
}
|
||
];
|
||
}
|
||
}else{
|
||
if(!self.isShowCustomView){
|
||
self.isShowCustomView = !self.isShowCustomView;
|
||
[UIView transitionWithView:self.customView duration:0.2 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.customView.transform = CGAffineTransformMakeTranslation(0, -self.customView.frame.size.height);
|
||
}
|
||
|
||
completion:^(BOOL isFinish){
|
||
|
||
}
|
||
];
|
||
}
|
||
}
|
||
|
||
}
|
||
-(void)showTimeOutToast{
|
||
if (!_hadShowTimeOut) {
|
||
_hadShowTimeOut=YES;
|
||
[self.searchMaskView hide:YES];
|
||
[self.view makeToast:NSLocalizedString(@"id_timeout", nil)];// 显示 连接超时
|
||
}
|
||
}
|
||
|
||
|
||
/*-(void)fButtonBackBeClick:(FounderButton*)fbt
|
||
{
|
||
if (!self.view.userInteractionEnabled) {
|
||
return;
|
||
}
|
||
[[P2PClient sharedClient] p2pHungUp];
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
}*/
|
||
#pragma mark - 视频回放准备播放的回调
|
||
-(void)P2PPlaybackReady:(NSDictionary *)info{
|
||
DLog(@"P2PPlaybackReady");
|
||
self.view.userInteractionEnabled = NO;
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[UIView transitionWithView:self.movieView duration:0.3 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.movieView.alpha = 0.3;
|
||
}
|
||
|
||
completion:^(BOOL finished){
|
||
[self.movieView setHidden:YES];
|
||
// P2PPlayingbackController *playingbackController = [[P2PPlayingbackController alloc] init];
|
||
// [self presentViewController:playingbackController animated:YES completion:nil];
|
||
// [playingbackController release];
|
||
|
||
P2PPlayingbackVC* playingbackController=[[P2PPlayingbackVC alloc] init];
|
||
[self presentViewController:playingbackController animated:YES completion:nil];
|
||
|
||
}
|
||
];
|
||
});
|
||
}
|
||
|
||
#pragma mark - 视频回放挂断的回调
|
||
-(void)P2PPlaybackReject:(NSDictionary *)info{
|
||
|
||
NSLog(@"P2PPlaybackReject");
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[UIView transitionWithView:self.movieView duration:0.3 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.movieView.alpha = 0.3;
|
||
}
|
||
|
||
completion:^(BOOL finished){
|
||
[self.movieView setHidden:YES];
|
||
[self.searchMaskView hide:YES];
|
||
[self.view makeToast:[info objectForKey:@"rejectMsg"]];
|
||
}
|
||
];
|
||
});
|
||
}
|
||
|
||
#pragma mark -
|
||
-(void)playbackPasswordModify:(YMsgBox*)box{
|
||
// NSLog(@"box.yMsgInputText=%@",box.yMsgInputText);
|
||
|
||
if(box.yMsgButtonIndex == -1 ){
|
||
return;
|
||
}
|
||
|
||
if(box.yMsgButtonIndex == -2){ //隐藏键盘 系统键盘return按钮被点击
|
||
[box hideKeyBoard];
|
||
return;
|
||
}
|
||
if(box.yMsgButtonIndex == 0){ //取消按钮被点击
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
// if ([box.theTagString isEqualToString:@"Msg_flist_pwd_error"]){
|
||
// _msgBoxFileListHadShow=NO;
|
||
// }
|
||
// if ([box.theTagString isEqualToString:@"Msg_sdcard_pwd_error"]){
|
||
// _msgBoxSDCardHadShow=NO;
|
||
// }
|
||
// [box hideMsgBox]; //隐藏输入框
|
||
}else{ //确认按钮被点击
|
||
if(box.yMsgInputText.length<=0){
|
||
box.yMsgText=[YFonc gtTextWithString:NSLocalizedString(@"password_can_not_be_empt", nil) withColor:[UIColor redColor] withFont:[UIFont systemFontOfSize:13.0] withAlignment:NSTextAlignmentLeft];
|
||
}else if(box.yMsgInputText.length>30){
|
||
box.yMsgText=[YFonc gtTextWithString:NSLocalizedString(@"device_password_too_long", nil) withColor:[UIColor redColor] withFont:[UIFont systemFontOfSize:13.0] withAlignment:NSTextAlignmentLeft];
|
||
}else{
|
||
|
||
[box hideMsgBox]; //隐藏输入框
|
||
if ([box.theTagString isEqualToString:@"Msg_flist_pwd_error"]){
|
||
_msgBoxPwdErrorHadShow=NO;
|
||
}
|
||
if ([box.theTagString isEqualToString:@"Msg_sdcard_pwd_error"]){
|
||
_msgBoxPwdErrorHadShow=NO;
|
||
}
|
||
NSString* pwdHead = PASSWORD_HEAD; //密码长度上限为30个字符
|
||
self.camera.cameraPass = [NSString stringWithFormat:@"%@%@", pwdHead, box.yMsgInputText];
|
||
//[[FListManager sharedFList] updatee:self.camera];
|
||
//[[FListManager sharedFList] getDefenceStates];
|
||
|
||
if ([box.theTagString isEqualToString:@"Msg_flist_pwd_error"]) {//获取列表文件错误,就重发获取列表的命令
|
||
[[P2PClient sharedClient] setCurrentLabel:1];
|
||
[[P2PClient sharedClient] getPlaybackFilesWithId:self.camera.cameraId password:self.camera.cameraPass timeInterval:1];
|
||
}
|
||
if ([box.theTagString isEqualToString:@"Msg_sdcard_pwd_error"]) {//sd卡密码错误,就重发获取SD卡的命令
|
||
self.isLoadingStorageInfo = YES;
|
||
[[P2PClient sharedClient] getSDCardInfoWithId:self.camera.cameraId password:self.camera.cameraPass];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#pragma mark -
|
||
-(BOOL)shouldAutorotate{
|
||
return YES;
|
||
}
|
||
|
||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface {
|
||
return (interface == UIInterfaceOrientationPortrait );
|
||
}
|
||
|
||
#ifdef IOS6
|
||
|
||
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
|
||
{
|
||
return UIInterfaceOrientationPortrait;
|
||
}
|
||
|
||
- (BOOL)shouldAutorotate {
|
||
return NO;
|
||
}
|
||
|
||
- (NSUInteger)supportedInterfaceOrientations {
|
||
return UIInterfaceOrientationMaskPortrait;
|
||
}
|
||
#endif
|
||
|
||
-(NSUInteger)supportedInterfaceOrientations{
|
||
return UIInterfaceOrientationMaskPortrait;
|
||
}
|
||
|
||
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
|
||
return UIInterfaceOrientationPortrait;
|
||
}
|
||
@end
|