Skip to content

Commit

Permalink
代码逻辑优化
Browse files Browse the repository at this point in the history
  • Loading branch information
onezens committed Jun 22, 2018
1 parent 8184352 commit 54b1dd9
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 152 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'TargetName' do
pod 'YCDownloadSession', '~> 1.2.5'
pod 'YCDownloadSession', '~> 1.2.6'
end
```

Expand Down
52 changes: 1 addition & 51 deletions YCDownloadSession.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "YCDownloadSession"
s.version = "1.2.5"
s.version = "1.2.6"
s.summary = "iOS background download video or file"
s.description = <<-DESC
iOS background download video or file lib
Expand All @@ -19,58 +19,8 @@ Pod::Spec.new do |s|
s.author = { "onezens" => "mail@onezen.cc" }
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/onezens/YCDownloadSession.git", :tag => "#{s.version}" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any swift, h, m, mm, c & cpp files.
# For header files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
#

s.source_files = "YCDownloadSession/YCDownloadSession/*.{h,m}"
# s.exclude_files = "Classes/Exclude"

s.public_header_files = "YCDownloadSession/YCDownloadSession/*.h"


# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
#

# s.resource = "icon.png"
# s.resources = "Resources/*.png"

# s.preserve_paths = "FilesToSave", "MoreFilesToSave"


# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
#

# s.framework = "SomeFramework"
# s.frameworks = "SomeFramework", "AnotherFramework"

# s.library = "iconv"
# s.libraries = "iconv", "xml2"


# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works.

s.requires_arc = true

# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# s.dependency "JSONKit", "~> 1.4"

end
10 changes: 10 additions & 0 deletions YCDownloadSession.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
3532E34220DC9D3300B3EF5B /* YCDownloadSession.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = YCDownloadSession.podspec; sourceTree = SOURCE_ROOT; };
353E94C11F7F3BC200B76CDF /* FastForwardView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FastForwardView.h; sourceTree = "<group>"; };
353E94C21F7F3BC200B76CDF /* FastForwardView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FastForwardView.m; sourceTree = "<group>"; };
353E94C31F7F3BC200B76CDF /* FastForwardView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FastForwardView.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -202,6 +203,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
3532E34120DC9D0E00B3EF5B /* Config */ = {
isa = PBXGroup;
children = (
3532E34220DC9D3300B3EF5B /* YCDownloadSession.podspec */,
);
path = Config;
sourceTree = "<group>";
};
353E94BF1F7F3BC200B76CDF /* WMPlayer */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -372,6 +381,7 @@
D72C84D31E77D42500EDCEEF /* Supporting Files */ = {
isa = PBXGroup;
children = (
3532E34120DC9D0E00B3EF5B /* Config */,
D72C84D41E77D42500EDCEEF /* main.m */,
);
name = "Supporting Files";
Expand Down
5 changes: 0 additions & 5 deletions YCDownloadSession/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ @implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

NSLog(@"launchOptions: %@",launchOptions);

// Override point for customization after application launch.
NSLog(@"%@", NSHomeDirectory());

//root vc
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
MainTableViewController *vc = [[MainTableViewController alloc] init];
Expand Down
33 changes: 9 additions & 24 deletions YCDownloadSession/YCDownloadSession/YCDownloadManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ - (void)initDownloadData {
}

- (void)saveDownloadItems {
[NSKeyedArchiver archiveRootObject:self.itemsDictM toFile:[self downloadItemSavePath]];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSLock *saveLock = [[NSLock alloc] init];
[saveLock lock];
[NSKeyedArchiver archiveRootObject:self.itemsDictM toFile:[self downloadItemSavePath]];
[saveLock unlock];

});
}

- (void)getDownloadItems {
Expand Down Expand Up @@ -207,7 +213,7 @@ + (NSString *)fileSizeStringFromBytes:(uint64_t)byteSize {
if (kCommonUtilsKilobyte <= byteSize) {
return [NSString stringWithFormat:@"%@KB", [self numberStringFromDouble:(double)byteSize / kCommonUtilsKilobyte]];
}
return [NSString stringWithFormat:@"%zdB", byteSize];
return [NSString stringWithFormat:@"%lluB", byteSize];
}


Expand All @@ -228,7 +234,6 @@ - (void)downloadUserChanged{
[self initDownloadData];
}


- (void)startDownloadWithItem:(YCDownloadItem *)item priority:(float)priority{
if(!item) return;
YCDownloadItem *oldItem = [self itemWithIdentifier:item.taskId];
Expand Down Expand Up @@ -398,34 +403,14 @@ - (void)downloadTaskFinishedNoti:(NSNotification *)noti{
- (void)localPushWithTitle:(NSString *)title detail:(NSString *)body {

if (!self.localPushOn || title.length == 0) return;

// 1.创建本地通知
UILocalNotification *localNote = [[UILocalNotification alloc] init];

// 2.设置本地通知的内容
// 2.1.设置通知发出的时间
localNote.fireDate = [NSDate dateWithTimeIntervalSinceNow:3.0];
// 2.2.设置通知的内容
localNote.alertBody = body;
// 2.3.设置滑块的文字(锁屏状态下:滑动来“解锁”)
localNote.alertAction = @"滑动来“解锁”";
// 2.4.决定alertAction是否生效
localNote.alertAction = @"滑动来解锁";
localNote.hasAction = NO;
// 2.5.设置点击通知的启动图片
// localNote.alertLaunchImage = @"123Abc";
// 2.6.设置alertTitle
// localNote.alertTitle = title;
// 2.7.设置有通知时的音效
localNote.soundName = @"default";
// 2.8.设置应用程序图标右上角的数字
localNote.applicationIconBadgeNumber = 0;

// 2.9.设置额外信息
localNote.userInfo = @{@"type" : @1};

// 3.调用通知
[[UIApplication sharedApplication] scheduleLocalNotification:localNote];

}

-(void)dealloc {
Expand Down
Loading

0 comments on commit 54b1dd9

Please sign in to comment.