From d845ed2cb077e9510d58edf7cd2445f806088fcc Mon Sep 17 00:00:00 2001 From: lianxiang <13052344590@163.com> Date: Fri, 19 Oct 2018 20:23:26 +0800 Subject: [PATCH] add --- GIGA.xcodeproj/project.pbxproj | 44 ++++++----- GIGA/AppDelegate.m | 7 +- GIGA/Common/GIGaDateHelper.h | 25 +++++++ GIGA/Common/GIGaDateHelper.m | 73 +++++++++++++++++++ GIGA/Common/GiGaUserDB/GiGaUserDefault.h | 4 + GIGA/Common/GiGaUserDB/GiGaUserDefault.m | 12 +++ GIGA/Common/LXCountTimer/LXCountTimer.h | 2 +- GIGA/Common/LXCountTimer/LXCountTimer.m | 36 +++++++++ GIGA/Config/GiGaServerConfig.m | 8 +- GIGA/Info.plist | 1 - .../Controller/GiGaMaskTaskViewController.m | 45 ++++++++---- .../Mask/View/MaskTimeCircularProgressView.m | 47 ++++++++++-- 12 files changed, 255 insertions(+), 49 deletions(-) create mode 100644 GIGA/Common/GIGaDateHelper.h create mode 100644 GIGA/Common/GIGaDateHelper.m diff --git a/GIGA.xcodeproj/project.pbxproj b/GIGA.xcodeproj/project.pbxproj index 9663035..ab84055 100644 --- a/GIGA.xcodeproj/project.pbxproj +++ b/GIGA.xcodeproj/project.pbxproj @@ -28,7 +28,6 @@ 8338F6B12142182200B4780B /* MaskTime.png in Resources */ = {isa = PBXBuildFile; fileRef = 8338F6B02142182100B4780B /* MaskTime.png */; }; 8338F6B92142504E00B4780B /* LXCustomSwith.m in Sources */ = {isa = PBXBuildFile; fileRef = 8338F6B82142504E00B4780B /* LXCustomSwith.m */; }; 833DA7762122A62000A5C614 /* GiGaMaskTaskViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */; }; - 833DE8E52150169F009D4329 /* JYAddressPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 833DE8E32150169F009D4329 /* JYAddressPicker.m */; }; 8340BF9E213E3846008F22E4 /* SHineLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8340BF9D213E3846008F22E4 /* SHineLabel.m */; }; 8340BFA2213E60DD008F22E4 /* GIGAMBHUDHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8340BFA1213E60DD008F22E4 /* GIGAMBHUDHelper.m */; }; 8340BFA6213E6514008F22E4 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8340BFA5213E6514008F22E4 /* Localizable.strings */; }; @@ -106,7 +105,6 @@ 836EE5D7213645E300F0ABB2 /* GiGaBaseAPiRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 836EE5D6213645E300F0ABB2 /* GiGaBaseAPiRequest.m */; }; 836EE5DA2136716100F0ABB2 /* NSTimer+Convenience.m in Sources */ = {isa = PBXBuildFile; fileRef = 836EE5D82136716000F0ABB2 /* NSTimer+Convenience.m */; }; 8376B81E2154897700AB79F8 /* GIGaUserFileHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8376B81D2154897700AB79F8 /* GIGaUserFileHelper.m */; }; - 8376B8202154913E00AB79F8 /* city.json in Resources */ = {isa = PBXBuildFile; fileRef = 8376B81F2154913E00AB79F8 /* city.json */; }; 8376B8232154927300AB79F8 /* GIGaMaskShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8376B8222154927300AB79F8 /* GIGaMaskShareViewController.m */; }; 8376B8282154A0A200AB79F8 /* MaskTimeEndViewImgaeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8376B8262154A0A200AB79F8 /* MaskTimeEndViewImgaeCell.m */; }; 8376B8292154A0A200AB79F8 /* MaskTimeEndViewImgaeCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8376B8272154A0A200AB79F8 /* MaskTimeEndViewImgaeCell.xib */; }; @@ -192,6 +190,9 @@ 838762E3214B9F580039D241 /* GiGaUserSexViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 838762E1214B9F580039D241 /* GiGaUserSexViewCell.xib */; }; 838762E7214B9FA60039D241 /* GIGaUserCityViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 838762E5214B9FA60039D241 /* GIGaUserCityViewCell.m */; }; 838762E8214B9FA60039D241 /* GIGaUserCityViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 838762E6214B9FA60039D241 /* GIGaUserCityViewCell.xib */; }; + 838CD5972179E11E000CBEA6 /* GIGaDateHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 838CD5962179E11E000CBEA6 /* GIGaDateHelper.m */; }; + 838CD5A22179E79C000CBEA6 /* city.json in Resources */ = {isa = PBXBuildFile; fileRef = 838CD5A02179E79C000CBEA6 /* city.json */; }; + 838CD5A32179E79C000CBEA6 /* JYAddressPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 838CD5A12179E79C000CBEA6 /* JYAddressPicker.m */; }; 8390116B214E20B2004CA790 /* LYSDateContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901145214E20B1004CA790 /* LYSDateContentView.m */; }; 8390116C214E20B2004CA790 /* LYSDatePopViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901149214E20B1004CA790 /* LYSDatePopViewController.m */; }; 8390116D214E20B2004CA790 /* LYSDateBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901151214E20B1004CA790 /* LYSDateBaseViewController.m */; }; @@ -302,8 +303,6 @@ 8338F6B82142504E00B4780B /* LXCustomSwith.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LXCustomSwith.m; sourceTree = ""; }; 833DA7742122A62000A5C614 /* GiGaMaskTaskViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaMaskTaskViewController.h; sourceTree = ""; }; 833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaMaskTaskViewController.m; sourceTree = ""; }; - 833DE8E12150169F009D4329 /* JYAddressPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JYAddressPicker.h; sourceTree = ""; }; - 833DE8E32150169F009D4329 /* JYAddressPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JYAddressPicker.m; sourceTree = ""; }; 8340BF9C213E3846008F22E4 /* SHineLabel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SHineLabel.h; sourceTree = ""; }; 8340BF9D213E3846008F22E4 /* SHineLabel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SHineLabel.m; sourceTree = ""; }; 8340BFA0213E60DD008F22E4 /* GIGAMBHUDHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GIGAMBHUDHelper.h; sourceTree = ""; }; @@ -439,7 +438,6 @@ 836EE5D92136716000F0ABB2 /* NSTimer+Convenience.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTimer+Convenience.h"; sourceTree = ""; }; 8376B81C2154897700AB79F8 /* GIGaUserFileHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GIGaUserFileHelper.h; sourceTree = ""; }; 8376B81D2154897700AB79F8 /* GIGaUserFileHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GIGaUserFileHelper.m; sourceTree = ""; }; - 8376B81F2154913E00AB79F8 /* city.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = city.json; sourceTree = ""; }; 8376B8212154927300AB79F8 /* GIGaMaskShareViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GIGaMaskShareViewController.h; sourceTree = ""; }; 8376B8222154927300AB79F8 /* GIGaMaskShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GIGaMaskShareViewController.m; sourceTree = ""; }; 8376B8252154A0A200AB79F8 /* MaskTimeEndViewImgaeCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MaskTimeEndViewImgaeCell.h; path = GIGA/Modules/Mask/View/MaskTimeEndViewImgaeCell.h; sourceTree = SOURCE_ROOT; }; @@ -589,6 +587,11 @@ 838762E4214B9FA60039D241 /* GIGaUserCityViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GIGaUserCityViewCell.h; sourceTree = ""; }; 838762E5214B9FA60039D241 /* GIGaUserCityViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GIGaUserCityViewCell.m; sourceTree = ""; }; 838762E6214B9FA60039D241 /* GIGaUserCityViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GIGaUserCityViewCell.xib; sourceTree = ""; }; + 838CD5952179E11D000CBEA6 /* GIGaDateHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GIGaDateHelper.h; sourceTree = ""; }; + 838CD5962179E11E000CBEA6 /* GIGaDateHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GIGaDateHelper.m; sourceTree = ""; }; + 838CD59F2179E79C000CBEA6 /* JYAddressPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JYAddressPicker.h; sourceTree = ""; }; + 838CD5A02179E79C000CBEA6 /* city.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = city.json; sourceTree = ""; }; + 838CD5A12179E79C000CBEA6 /* JYAddressPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JYAddressPicker.m; sourceTree = ""; }; 83901142214E04D1004CA790 /* ApiRequestConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApiRequestConfig.h; sourceTree = ""; }; 83901144214E20B1004CA790 /* LYSDatePickerTypeDayAndTimeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerTypeDayAndTimeDelegate.h; sourceTree = ""; }; 83901145214E20B1004CA790 /* LYSDateContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDateContentView.m; sourceTree = ""; }; @@ -774,17 +777,6 @@ path = CustomSwitch; sourceTree = ""; }; - 833DE8E02150169F009D4329 /* JYAddressPicker */ = { - isa = PBXGroup; - children = ( - 8376B81F2154913E00AB79F8 /* city.json */, - 833DE8E12150169F009D4329 /* JYAddressPicker.h */, - 833DE8E32150169F009D4329 /* JYAddressPicker.m */, - ); - name = JYAddressPicker; - path = ../../../../JYAddressPicker; - sourceTree = ""; - }; 8340BF9F213E6080008F22E4 /* GIGAMBHUDHelper */ = { isa = PBXGroup; children = ( @@ -807,9 +799,9 @@ 8340BFAC213E7374008F22E4 /* Views */ = { isa = PBXGroup; children = ( + 838CD59E2179E79C000CBEA6 /* JYAddressPicker */, 83276184216F29A800C6216C /* LXCustomActionsheet */, 8382DFC021564A1F00BBA5A5 /* SJPhotoPicker */, - 833DE8E02150169F009D4329 /* JYAddressPicker */, 83901143214E20B1004CA790 /* LYSDatePickerController */, 8338F6B62142504E00B4780B /* CustomSwitch */, 8340BFAD213E739D008F22E4 /* GiGaNoNetWorkView.h */, @@ -1027,6 +1019,8 @@ 8361B3FC21215C7400238FEB /* Common */ = { isa = PBXGroup; children = ( + 838CD5952179E11D000CBEA6 /* GIGaDateHelper.h */, + 838CD5962179E11E000CBEA6 /* GIGaDateHelper.m */, 8340BFAC213E7374008F22E4 /* Views */, 8340BF9F213E6080008F22E4 /* GIGAMBHUDHelper */, 83928FFF2134F4230077D2E8 /* LXDanMuManager */, @@ -1553,6 +1547,17 @@ path = userInfoView; sourceTree = ""; }; + 838CD59E2179E79C000CBEA6 /* JYAddressPicker */ = { + isa = PBXGroup; + children = ( + 838CD59F2179E79C000CBEA6 /* JYAddressPicker.h */, + 838CD5A02179E79C000CBEA6 /* city.json */, + 838CD5A12179E79C000CBEA6 /* JYAddressPicker.m */, + ); + name = JYAddressPicker; + path = "../../../../../MaskTime素材新/JYAddressPicker"; + sourceTree = ""; + }; 83901143214E20B1004CA790 /* LYSDatePickerController */ = { isa = PBXGroup; children = ( @@ -1863,13 +1868,13 @@ 834BDA48215C7D10001E1DB7 /* InfoPlist.strings in Resources */, 8382DFEF21564A1F00BBA5A5 /* photopicker_back.png in Resources */, 83BFAE68213CCF10004EF801 /* GiGaMineUserViewCell.xib in Resources */, - 8376B8202154913E00AB79F8 /* city.json in Resources */, 8351474221521C2A00B25A88 /* GIGaChangePassVC.xib in Resources */, 8382DFAD215626CE00BBA5A5 /* GiGaFeedContentViewCell.xib in Resources */, 8340BFA9213E65CA008F22E4 /* GIGACommonLocalizabe.strings in Resources */, 83835BA8212E4748001480F2 /* MAssaageCenterCell.xib in Resources */, 8361B3D3212155C300238FEB /* Assets.xcassets in Resources */, 8340BFA6213E6514008F22E4 /* Localizable.strings in Resources */, + 838CD5A22179E79C000CBEA6 /* city.json in Resources */, 8361B3D1212155C200238FEB /* Main.storyboard in Resources */, 8376B8412154CEB200AB79F8 /* MaskShareTimeMidViewCell.xib in Resources */, 8340BFAB213E665D008F22E4 /* GIGAUserLocalizable.strings in Resources */, @@ -2006,6 +2011,7 @@ 8361B4382121847600238FEB /* UINavigationBar+Custom.m in Sources */, 83BFAE6C213CD0E3004EF801 /* GiGaMineInfoViewCell.m in Sources */, 834DA5A8215F5FE0003FC4C6 /* ShareCustomIamgeModel.m in Sources */, + 838CD5A32179E79C000CBEA6 /* JYAddressPicker.m in Sources */, 8376B8402154CEB200AB79F8 /* MaskShareTimeMidViewCell.m in Sources */, 8390116B214E20B2004CA790 /* LYSDateContentView.m in Sources */, 83BC8A872148BE8A00820437 /* NYPopover.m in Sources */, @@ -2095,6 +2101,7 @@ 8357ADD32123C7C6000816F2 /* GiGaAPIResult.m in Sources */, 8340BF9E213E3846008F22E4 /* SHineLabel.m in Sources */, 8342FD862150FD5200D141F4 /* VersionModel.m in Sources */, + 838CD5972179E11E000CBEA6 /* GIGaDateHelper.m in Sources */, 838762D3214B9D120039D241 /* GIGaUserInfoAvatorCell.m in Sources */, 8361B4352121836700238FEB /* GiGaBaseNavViewController.m in Sources */, 835060B3212D54C2007E6220 /* GiGaAdDetailViewController.m in Sources */, @@ -2109,7 +2116,6 @@ 8382DFEB21564A1F00BBA5A5 /* SJPreviewPhotoController.m in Sources */, 8376B81E2154897700AB79F8 /* GIGaUserFileHelper.m in Sources */, 8376B8362154C74300AB79F8 /* ShareViewController.m in Sources */, - 833DE8E52150169F009D4329 /* JYAddressPicker.m in Sources */, 834127212152AEFB001DDB36 /* GIGaMaskTimeUseRecordVC.m in Sources */, 83901171214E20B2004CA790 /* LYSDatePickerLabel.m in Sources */, 83C78A14215873170083DDD9 /* MaskHistoryListViewCell.m in Sources */, diff --git a/GIGA/AppDelegate.m b/GIGA/AppDelegate.m index 8ab176b..ea7f6fc 100644 --- a/GIGA/AppDelegate.m +++ b/GIGA/AppDelegate.m @@ -27,8 +27,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. //[NSThread sleepForTimeInterval:1];//延迟启动 - - _isMasking = NO; + self.isMasking = [GiGaUserDefault isMasking]; + //_isMasking = NO; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [self registLocalNotification]; [self configThridPartyWithOptions:launchOptions]; @@ -138,7 +138,7 @@ - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - + [GiGaUserDefault saveisMaskingflag:_isMasking]; //app 挂起 面膜时间未结束 发送本地通知提醒 if (_isMasking) { @@ -147,6 +147,7 @@ // [[GiGaLocalNotificationManager localNotifiationCenter] cancelAllLocalNoitification]; } [[GiGaLocalNotificationManager localNotifiationCenter] cancelAllLocalNoitification]; + } -(void)remoteControlReceivedWithEvent:(UIEvent *)event diff --git a/GIGA/Common/GIGaDateHelper.h b/GIGA/Common/GIGaDateHelper.h new file mode 100644 index 0000000..c36d623 --- /dev/null +++ b/GIGA/Common/GIGaDateHelper.h @@ -0,0 +1,25 @@ +// +// GIGaDateHelper.h +// MasKTimeCountTime +// +// Created by lianxiang on 2018/10/19. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface GIGaDateHelper : NSObject + ++(NSString *)getNowTimeTimestamp2; ++(NSDate *)getStartDate; ++(void)saveSatrtDate; ++(int)getTimebySubtracting:(NSDate*)Date1 andDate2:(NSDate*)Date2; ++(void)saveisMaskingflag:(BOOL)masking; ++(BOOL)isMasking; ++(void)removeStartDate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/GIGA/Common/GIGaDateHelper.m b/GIGA/Common/GIGaDateHelper.m new file mode 100644 index 0000000..408231b --- /dev/null +++ b/GIGA/Common/GIGaDateHelper.m @@ -0,0 +1,73 @@ +// +// GIGaDateHelper.m +// MasKTimeCountTime +// +// Created by lianxiang on 2018/10/19. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import "GIGaDateHelper.h" + +@implementation GIGaDateHelper + +//获取当前时间 单位秒 ++(NSString *)getNowTimeTimestamp2{ + + NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0]; + NSLog(@"date :%@",dat); + + NSTimeInterval a=[dat timeIntervalSince1970]; + NSString*timeString = [NSString stringWithFormat:@"%0.f", a]; + //转为字符型 ; + return timeString; + +} + ++(NSDate *)getStartDate{ + + NSDate *start = [[NSUserDefaults standardUserDefaults] objectForKey:@"start"]; + + return start; + +} + ++(void )saveSatrtDate{ + + NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0]; + [[NSUserDefaults standardUserDefaults] setObject:dat forKey:@"start"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + +} + ++(void)removeStartDate{ + + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"start"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + +} + ++(int)getTimebySubtracting:(NSDate*)Date1 andDate2:(NSDate*)Date2 +{ + NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; + unsigned int unitFlags = NSCalendarUnitSecond; + + NSDateComponents *comps = [gregorian components: unitFlags fromDate:Date1 toDate:Date2 options:0]; + + int seconds = (int)[comps second]; + + return seconds; +} + ++(void)saveisMaskingflag:(BOOL)masking{ + [[NSUserDefaults standardUserDefaults] setBool:masking forKey:@"isMasking"]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + ++(BOOL)isMasking{ + + BOOL ismasking = [[NSUserDefaults standardUserDefaults] boolForKey:@"isMasking"]; + return ismasking; + +} + +@end diff --git a/GIGA/Common/GiGaUserDB/GiGaUserDefault.h b/GIGA/Common/GiGaUserDB/GiGaUserDefault.h index b2da30f..318c443 100644 --- a/GIGA/Common/GiGaUserDB/GiGaUserDefault.h +++ b/GIGA/Common/GiGaUserDB/GiGaUserDefault.h @@ -75,4 +75,8 @@ +(void)saveUserTestFlag:(BOOL)tested; +(BOOL)isUserTest; + ++(void)saveisMaskingflag:(BOOL)masking; ++(BOOL)isMasking; + @end diff --git a/GIGA/Common/GiGaUserDB/GiGaUserDefault.m b/GIGA/Common/GiGaUserDB/GiGaUserDefault.m index 0dbd1d8..e090cb3 100644 --- a/GIGA/Common/GiGaUserDB/GiGaUserDefault.m +++ b/GIGA/Common/GiGaUserDB/GiGaUserDefault.m @@ -166,4 +166,16 @@ NSString *const kShowUserTested = @"kShowUserTested"; return showedGaurd; } ++(void)saveisMaskingflag:(BOOL)masking{ + [[NSUserDefaults standardUserDefaults] setBool:masking forKey:@"isMasking"]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + ++(BOOL)isMasking{ + + BOOL ismasking = [[NSUserDefaults standardUserDefaults] boolForKey:@"isMasking"]; + return ismasking; + +} + @end diff --git a/GIGA/Common/LXCountTimer/LXCountTimer.h b/GIGA/Common/LXCountTimer/LXCountTimer.h index a64a96d..3973b79 100644 --- a/GIGA/Common/LXCountTimer/LXCountTimer.h +++ b/GIGA/Common/LXCountTimer/LXCountTimer.h @@ -15,7 +15,7 @@ * finishTimeStamp 结束的时间戳 */ -(void)countDownWithStratTimeStamp:(long)starTimeStamp finishTimeStamp:(long)finishTimeStamp completeBlock:(void (^)(NSInteger day,NSInteger hour,NSInteger minute,NSInteger second))completeBlock; - +-(void)countDownWithtimerInterval:(NSTimeInterval)timerInterval completeBlock:(void (^)(NSInteger day, NSInteger hour, NSInteger minute, NSInteger second))completeBlock; /** * 每秒走一次,回调block diff --git a/GIGA/Common/LXCountTimer/LXCountTimer.m b/GIGA/Common/LXCountTimer/LXCountTimer.m index 28268a3..34d5d0e 100644 --- a/GIGA/Common/LXCountTimer/LXCountTimer.m +++ b/GIGA/Common/LXCountTimer/LXCountTimer.m @@ -54,6 +54,42 @@ } } +-(void)countDownWithtimerInterval:(NSTimeInterval)timerInterval completeBlock:(void (^)(NSInteger, NSInteger, NSInteger, NSInteger))completeBlock{ + + if (_timer == nil) { + + __block int timeout = timerInterval; + if (timeout !=0) { + + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); + dispatch_source_set_timer(_timer, dispatch_walltime(NULL, 0), 1.0*NSEC_PER_SEC, 0);//每秒执行 + dispatch_source_set_event_handler(_timer, ^{ + if (timeout<=0) { + //记时结束, 关闭 + dispatch_source_cancel(self->_timer); + self->_timer = nil; + dispatch_async(dispatch_get_main_queue(), ^{ + completeBlock(0,0,0,0); + }); + }else{ + int days = (int)(timeout/(3600*24)); + int hours = (int)((timeout-days*24*3600)/3600); + int minute = (int)(timeout-days*24*3600-hours*3600)/60; + int second = timeout-days*24*3600-hours*3600-minute*60; + dispatch_async(dispatch_get_main_queue(), ^{ + completeBlock(days,hours,minute,second); + }); + timeout--; + } + }); + dispatch_resume(_timer); + } + + } +} + + -(void)countDownWithPER_SECBlock:(void (^)(void))PER_SECBlock{ if (_timer==nil) { dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); diff --git a/GIGA/Config/GiGaServerConfig.m b/GIGA/Config/GiGaServerConfig.m index a801557..8f7aa4a 100644 --- a/GIGA/Config/GiGaServerConfig.m +++ b/GIGA/Config/GiGaServerConfig.m @@ -19,10 +19,10 @@ case 0://测试环境 { -// [[NSUserDefaults standardUserDefaults] setValue:@"http://apiyts.s1.natapp.cc/v1/" forKey:@"MainUrl"]; -// [[NSUserDefaults standardUserDefaults] setValue:@"http://wsyts.s1.natapp.cc" forKey:@"gigasocketUrl"]; - [[NSUserDefaults standardUserDefaults] setValue:@"https://api.mianmoshijian.com/v1/" forKey:@"MainUrl"]; - [[NSUserDefaults standardUserDefaults] setValue:@"https://ws.mianmoshijian.com" forKey:@"gigasocketUrl"]; + [[NSUserDefaults standardUserDefaults] setValue:@"http://apiyts.s1.natapp.cc/v1/" forKey:@"MainUrl"]; + [[NSUserDefaults standardUserDefaults] setValue:@"http://wsyts.s1.natapp.cc" forKey:@"gigasocketUrl"]; +// [[NSUserDefaults standardUserDefaults] setValue:@"https://api.mianmoshijian.com/v1/" forKey:@"MainUrl"]; +// [[NSUserDefaults standardUserDefaults] setValue:@"https://ws.mianmoshijian.com" forKey:@"gigasocketUrl"]; } break; diff --git a/GIGA/Info.plist b/GIGA/Info.plist index 480e072..b9f61e3 100644 --- a/GIGA/Info.plist +++ b/GIGA/Info.plist @@ -54,7 +54,6 @@ 是否允许此App使用您的相册? UIBackgroundModes - audio remote-notification UILaunchStoryboardName diff --git a/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m b/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m index 1e27944..8344941 100644 --- a/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m +++ b/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m @@ -36,10 +36,11 @@ #import "MaskHistryRecord.h" #import "MaskTimeTopAnimationView.h" #import +#import "GIGaDateHelper.h" @interface GiGaMaskTaskViewController () { - AVAudioPlayer *_musicPalyer; + AVAudioPlayer *_startMaskMusic; } @@ -258,8 +259,25 @@ [self setUpNav]; [self initUI]; [self addNotify]; - [self creatBackGroundMusic]; + //[self creatBackGroundMusic]; [self creatMaskTimeSatrtMusic]; + //判断是否有倒数计时 + [self digIsMasking]; + +} + +-(void)digIsMasking{ + AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate]; + NSString *st = nil; + if (delegate.isMasking) { + NSLog(@"倒计时中"); + st = @"YES"; + [self animaMask]; + + }else{ + st = @"NO"; + + } } @@ -288,6 +306,8 @@ [self.cicleProgressView stop]; //手动结束时结束peding通知 [[GiGaLocalNotificationManager localNotifiationCenter] cancelAllLocalNoitification]; + [GIGaDateHelper removeStartDate]; + [GIGaDateHelper saveisMaskingflag:NO]; [self maskTimeEnd]; } }]; @@ -473,7 +493,7 @@ AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:musicUrl error:&payerError]; player.numberOfLoops = -1;//-1 无限 player.volume = 0; - _musicPalyer = player; + //_musicPalyer = player; [[AVAudioSession sharedInstance] setActive:YES error:nil]; //设置后台模式和锁屏模式下依然能够播放 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; @@ -502,18 +522,14 @@ [self sendBengainMaskTime]; [self createInputView]; //出现弹幕 AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate]; - if (delegate.isMasking) { - return; - } + NSTimeInterval timeInterVal = [GiGaUserDefault getUserMaskeTime]; + [self.cicleProgressView startWith:timeInterVal]; + delegate.isMasking = YES; [_startMaskMusic play]; - [_musicPalyer play]; + //[_musicPalyer play]; // [self setBackGroundPlayingInfo];//锁屏音频信息 - - //总时间隔 s - NSTimeInterval timeInterVal = [GiGaUserDefault getUserMaskeTime]; - - [self.cicleProgressView startWith:timeInterVal]; + //底部弹窗 //[self showWaringView]; @@ -563,13 +579,15 @@ #pragma mark 面膜时间结束 -(void)maskTimeEnd{ + self.openDanmuButton.hidden = YES; [self sendEndMaskTime]; NC_POST_NAME_OBJECT(kUserNoti_MASKEND, nil); //面膜时间结束时设置 全局变量 不再发送本地通知 提醒 AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate]; delegate.isMasking = NO; - [_musicPalyer stop]; + + //[_musicPalyer stop]; //震动 需用户手动开启震动模式 AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); @@ -792,6 +810,7 @@ [UIView animateWithDuration:0.4 animations:^{ self.waringView.frame = CGRectMake(0,CGRectGetMaxY(self.view.frame) - 44 - PhoneX_BottomMargin, self.view.frame.size.width, 44); }]; + [self.waringView showView]; } diff --git a/GIGA/Modules/Mask/View/MaskTimeCircularProgressView.m b/GIGA/Modules/Mask/View/MaskTimeCircularProgressView.m index 772b414..280abc5 100644 --- a/GIGA/Modules/Mask/View/MaskTimeCircularProgressView.m +++ b/GIGA/Modules/Mask/View/MaskTimeCircularProgressView.m @@ -9,6 +9,8 @@ #import "MaskTimeCircularProgressView.h" #import "LXCountTimer.h" #import "SHineLabel.h" +#import "GIGaDateHelper.h" +#import "AppDelegate.h" @interface MaskTimeCircularProgressView() @property (nonatomic) CADisplayLink *displayLink; @@ -20,7 +22,6 @@ @property (nonatomic,strong) NSTimer *playTimer; @property (nonatomic,strong) UIImageView *holderImageView; - @end @implementation MaskTimeCircularProgressView @@ -145,8 +146,8 @@ slice.lineCap = kCALineJoinRound; slice.lineJoin = kCALineJoinBevel; slice.path = smoothedPath.CGPath; - return slice; + } - (void)setProgress:(float)progress{ @@ -180,7 +181,10 @@ - (void)startWith:(NSTimeInterval)time{ self.timeinterval = time; + [self countDown:time]; + + //进度圆环 [self start]; } @@ -200,13 +204,37 @@ -(void)countDown:(NSTimeInterval)timeInterVal{ - NSString *timeformat = [GiGaHelper stringWithNSTimerinterval:timeInterVal]; - NSArray *timesArr = [timeformat componentsSeparatedByString:@":"]; - NSString *hour = timesArr[0]; - NSString *min = timesArr[1]; - NSString *sec = timesArr[2]; - [self countTimeBegain:hour.integerValue minute:min.integerValue second:sec.integerValue]; + AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate]; + if (delegate.isMasking) { + + }else{ + + [GIGaDateHelper saveSatrtDate]; + } + + NSDate *startDate = [GIGaDateHelper getStartDate]; + NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0]; + if (startDate == nil) { + startDate = dat; + } + + NSTimeInterval passt = [GIGaDateHelper getTimebySubtracting:startDate andDate2:dat]; + NSLog(@"passT %0.f",passt); + + NSTimeInterval cunrenShowTimCount = timeInterVal > passt ? timeInterVal - passt: timeInterVal; + delegate.isMasking= YES; + weakify(self); + [self.timer countDownWithtimerInterval:cunrenShowTimCount completeBlock:^(NSInteger day, NSInteger hour, NSInteger minute, NSInteger second) { + [weakSelf refreshTimeCount:hour minute:minute second:second]; + if (minute==0 && second == 0) { + delegate.isMasking = NO; + [GIGaDateHelper removeStartDate]; + [GIGaDateHelper saveisMaskingflag:NO]; + + } + }]; + } #pragma mark 开始计时 @@ -218,8 +246,11 @@ [self.timer countDownWithStratTimeStamp:nowTimestamp finishTimeStamp:futrueTimestamp completeBlock:^(NSInteger day, NSInteger hour, NSInteger minute, NSInteger second) { [weakSelf refreshTimeCount:hour minute:minute second:second]; }]; + } + + -(void)refreshTimeCount:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second{ self.countLabel.text = [NSString stringWithFormat:@"%02ld:%02ld",minute,second];