Browse Source

Task list actions

HonorLee 8 years ago
parent
commit
386735f4de

+ 1 - 1
ShareSupport/ShareViewController.h

@@ -17,4 +17,4 @@
 - (IBAction)Analyse:(id)sender;
 @property (strong, nonatomic) IBOutlet UIBarButtonItem *FirstNextBtn;
 
-@end
+@end

+ 23 - 7
ShareSupport/ShareViewController.m

@@ -20,7 +20,7 @@
 @property UIActivityIndicatorView *indicator;
 @property UILabel *StatusLabel;
 @property UIButton *DoneBtn;
-@property NSString *RealVideoID;
+@property NSDictionary *tumblrData;
 
 @end
 
@@ -42,7 +42,7 @@
             _SharedURL = url.absoluteString;
             dispatch_async(dispatch_get_main_queue(), ^{
                  [_FistViewURLText setText:_SharedURL];
-                NSLog(@"%@",_SharedURL);
+//                NSLog(@"%@",_SharedURL);
             });
             if(![_SharedURL containsString:@"tumblr.com"]){
                 [_FirstNextBtn setEnabled:NO];
@@ -110,12 +110,25 @@
         if([eles count]>0){
             ele = [eles objectAtIndex:0];
             secURL = [ele objectForKey:@"src"];
-            NSLog(@"%@",secURL);
+//            NSLog(@"%@",secURL);
     
             NSRegularExpression *videoRegex = [NSRegularExpression regularExpressionWithPattern:@"tumblr_[a-zA-Z0-9]+" options:NSRegularExpressionCaseInsensitive error:&error] ;
+            if (error) {
+                [self onError];
+                return;
+            }
             NSTextCheckingResult *r = [videoRegex firstMatchInString:secURL options:NSMatchingReportCompletion range:NSMakeRange(0, secURL.length)];
-    
-            _RealVideoID = [secURL substringWithRange:r.range];
+            
+            NSString *videoID = nil;
+            NSString *imgURL = nil;
+            
+            videoID = [secURL substringWithRange:r.range];
+            eles = [doc searchWithXPathQuery:@"//video[@poster]"];
+            if([eles count]>0){
+                ele = [eles objectAtIndex:0];
+                imgURL = [ele objectForKey:@"poster"];
+            }
+            _tumblrData = [[NSDictionary alloc] initWithObjectsAndKeys:videoID,@"videoID",imgURL,@"imgURL", nil];
             [self success];
         }else{
             [self onError];
@@ -151,10 +164,13 @@
     _userDefaults = [[NSUserDefaults alloc]initWithSuiteName:@"group.honorlee.TDGroup"];
     [_userDefaults synchronize];
     NSMutableArray *tmpData = [NSMutableArray arrayWithArray:(NSMutableArray *)[_userDefaults objectForKey:@"tasks"]];
-    [tmpData addObject:_RealVideoID];
+    if([tmpData count]==0){
+        tmpData = [[NSMutableArray alloc]init];
+    }
+    [tmpData addObject:_tumblrData];
     [_userDefaults setObject:tmpData forKey:@"tasks"];
     [_userDefaults synchronize];
-
+    NSLog(@"%@",_tumblrData);
     [self finish:nil];
 }
 @end

+ 6 - 0
TumblrDownloader.xcodeproj/project.pbxproj

@@ -9,6 +9,7 @@
 /* Begin PBXBuildFile section */
 		D30DC0C01C4F68C300545EF1 /* TumblrDownloader.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = D386B1301C469FDB00D7E0C5 /* TumblrDownloader.entitlements */; };
 		D30DC0C11C4F68C700545EF1 /* ShareSupport.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = D386B1311C46A0F900D7E0C5 /* ShareSupport.entitlements */; };
+		D30DC0D31C50CDF900545EF1 /* ImageHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = D30DC0D21C50CDF900545EF1 /* ImageHandler.m */; };
 		D3166D7C1C48F3F50003B6B8 /* Downloader.m in Sources */ = {isa = PBXBuildFile; fileRef = D3166D7B1C48F3F50003B6B8 /* Downloader.m */; };
 		D3166D811C48F9C20003B6B8 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D3166D831C48F9C20003B6B8 /* Localizable.strings */; };
 		D36ACDC71C44D07E00B2C7CF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D36ACDC61C44D07E00B2C7CF /* main.m */; };
@@ -68,6 +69,8 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+		D30DC0D11C50CDF900545EF1 /* ImageHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageHandler.h; sourceTree = "<group>"; };
+		D30DC0D21C50CDF900545EF1 /* ImageHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageHandler.m; sourceTree = "<group>"; };
 		D3166D7A1C48F3F50003B6B8 /* Downloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Downloader.h; sourceTree = "<group>"; };
 		D3166D7B1C48F3F50003B6B8 /* Downloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Downloader.m; sourceTree = "<group>"; };
 		D3166D821C48F9C20003B6B8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -183,6 +186,8 @@
 				D386B1751C4BB08900D7E0C5 /* TasksViewController.m */,
 				D386B1521C4B64DB00D7E0C5 /* HelpViewController.h */,
 				D386B1531C4B64DB00D7E0C5 /* HelpViewController.m */,
+				D30DC0D11C50CDF900545EF1 /* ImageHandler.h */,
+				D30DC0D21C50CDF900545EF1 /* ImageHandler.m */,
 			);
 			path = TumblrDownloader;
 			sourceTree = "<group>";
@@ -384,6 +389,7 @@
 				D36ACDCA1C44D07E00B2C7CF /* AppDelegate.m in Sources */,
 				D386B1541C4B64DB00D7E0C5 /* HelpViewController.m in Sources */,
 				D386B1791C4BD42500D7E0C5 /* DownloadQueenViewController.m in Sources */,
+				D30DC0D31C50CDF900545EF1 /* ImageHandler.m in Sources */,
 				D3166D7C1C48F3F50003B6B8 /* Downloader.m in Sources */,
 				D36ACDC71C44D07E00B2C7CF /* main.m in Sources */,
 				D386B1721C4B954B00D7E0C5 /* MBProgressHUD.m in Sources */,

BIN
TumblrDownloader.xcodeproj/project.xcworkspace/xcuserdata/HonorLee.xcuserdatad/UserInterfaceState.xcuserstate


+ 23 - 31
TumblrDownloader/Base.lproj/Main.storyboard

@@ -17,19 +17,19 @@
                         <rect key="frame" x="0.0" y="0.0" width="600" height="551"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="DA9-pA-54O">
+                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="DA9-pA-54O">
                                 <rect key="frame" x="0.0" y="64" width="600" height="487"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                 <prototypes>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="TaskCellStyle" textLabel="SwI-IC-cbA" style="IBUITableViewCellStyleDefault" id="4y4-cp-ZPb">
-                                        <rect key="frame" x="0.0" y="28" width="600" height="44"/>
+                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="TaskCellStyle" textLabel="Shx-0K-vxh" rowHeight="80" style="IBUITableViewCellStyleDefault" id="4y4-cp-ZPb">
+                                        <rect key="frame" x="0.0" y="28" width="600" height="80"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="4y4-cp-ZPb" id="xxK-hZ-vB4">
-                                            <rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="600" height="79.5"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
-                                                <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="SwI-IC-cbA">
-                                                    <rect key="frame" x="15" y="0.0" width="570" height="43.5"/>
+                                                <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Shx-0K-vxh">
+                                                    <rect key="frame" x="15" y="0.0" width="570" height="79.5"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                                     <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
@@ -38,21 +38,26 @@
                                             </subviews>
                                         </tableViewCellContentView>
                                     </tableViewCell>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="FkJ-Bj-VLX">
-                                        <rect key="frame" x="0.0" y="72" width="600" height="44"/>
-                                        <autoresizingMask key="autoresizingMask"/>
-                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="FkJ-Bj-VLX" id="fYq-6I-gKJ">
-                                            <rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
-                                            <autoresizingMask key="autoresizingMask"/>
-                                        </tableViewCellContentView>
-                                    </tableViewCell>
                                 </prototypes>
                             </tableView>
                             <navigationBar contentMode="scaleToFill" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vdl-3W-IOG">
                                 <rect key="frame" x="0.0" y="20" width="600" height="44"/>
                                 <color key="barTintColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                                 <items>
-                                    <navigationItem title="任务" id="gWa-wn-rsp"/>
+                                    <navigationItem title="任务" id="gWa-wn-rsp">
+                                        <barButtonItem key="leftBarButtonItem" title="全部开始" style="plain" id="hF5-Nl-RCd">
+                                            <color key="tintColor" red="0.0" green="0.67873574810000004" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                            <connections>
+                                                <action selector="EditAll:" destination="lRI-Iw-dTA" id="Hpl-Xi-uoJ"/>
+                                            </connections>
+                                        </barButtonItem>
+                                        <barButtonItem key="rightBarButtonItem" title="编辑" style="plain" id="gDO-72-971">
+                                            <color key="tintColor" red="0.0" green="0.75474880580000003" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                            <connections>
+                                                <action selector="EditTaskList:" destination="lRI-Iw-dTA" id="OUb-78-E2J"/>
+                                            </connections>
+                                        </barButtonItem>
+                                    </navigationItem>
                                 </items>
                             </navigationBar>
                         </subviews>
@@ -69,6 +74,7 @@
                     </view>
                     <tabBarItem key="tabBarItem" title="任务" image="tab_libraries.png" id="Uvb-Oj-AKd"/>
                     <connections>
+                        <outlet property="AllEditBtn" destination="hF5-Nl-RCd" id="40D-Su-MbV"/>
                         <outlet property="TaskTableView" destination="DA9-pA-54O" id="96O-lk-ESd"/>
                     </connections>
                 </viewController>
@@ -92,27 +98,13 @@
                                 <rect key="frame" x="0.0" y="20" width="600" height="44"/>
                                 <color key="barTintColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                                 <items>
-                                    <navigationItem id="w8P-bn-jwE">
-                                        <nil key="title"/>
-                                        <segmentedControl key="titleView" opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" segmentControlStyle="bar" selectedSegmentIndex="0" id="owk-ve-bc0">
-                                            <rect key="frame" x="230" y="7" width="140" height="30"/>
-                                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                            <segments>
-                                                <segment title="视频"/>
-                                                <segment title="图片"/>
-                                            </segments>
-                                            <color key="tintColor" cocoaTouchSystemColor="viewFlipsideBackgroundColor"/>
-                                        </segmentedControl>
+                                    <navigationItem title="已下载" id="w8P-bn-jwE">
                                         <barButtonItem key="rightBarButtonItem" title="Item" id="FU9-Yl-eGz"/>
                                     </navigationItem>
                                 </items>
                             </navigationBar>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="n88-dw-upa">
-                                <rect key="frame" x="187" y="328" width="240" height="128"/>
-                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
-                            </tableView>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="OmZ-IJ-7QL">
-                                <rect key="frame" x="0.0" y="64" width="240" height="128"/>
+                                <rect key="frame" x="0.0" y="64" width="600" height="487"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                             </tableView>
                         </subviews>

+ 13 - 0
TumblrDownloader/ImageHandler.h

@@ -0,0 +1,13 @@
+//
+//  ImageHandler.h
+//  TumblrDownloader
+//
+//  Created by HonorLee on 16/1/21.
+//  Copyright © 2016年 HonorLee. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+@interface ImageHandler : NSObject
++(NSString *)getAndSaveThumbImageFromURLandSetToImageView:(NSString *)imagePath saveToName:(NSString *)fileName setToImage:(UIImageView *)imageView;
+@end

+ 68 - 0
TumblrDownloader/ImageHandler.m

@@ -0,0 +1,68 @@
+//
+//  ImageHandler.m
+//  TumblrDownloader
+//
+//  Created by HonorLee on 16/1/21.
+//  Copyright © 2016年 HonorLee. All rights reserved.
+//
+
+#import "ImageHandler.h"
+
+@implementation ImageHandler
++(NSString *)getAndSaveThumbImageFromURLandSetToImageView:(NSString *)imagePath saveToName:(NSString *)fileName setToImage:(UIImageView *)imageView{
+    UIImage *oldImg;
+    UIImage *newImg;
+    NSData *imgData;
+    NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"/Library/Caches/%@.jpg",fileName]];
+    NSLog(@"%@",filePath);
+    BOOL needSave = NO;
+    BOOL onError = NO;
+    NSError * error;
+    dispatch_group_t disG = dispatch_group_create();
+    
+    dispatch_group_enter(disG);
+    if([imagePath containsString:@"http"]){
+        needSave = YES;
+        imgData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imagePath]];
+    }else{
+        imgData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error];
+    }
+    if(error)
+    {
+        NSLog(@"%@",error);
+    }
+
+    if(imgData){
+        if(needSave){
+            oldImg = [UIImage imageWithData:imgData];
+            UIGraphicsBeginImageContext(CGSizeMake(60, 60));
+            [oldImg drawInRect:CGRectMake(0, 0, 60, 60)];
+            newImg = UIGraphicsGetImageFromCurrentImageContext();
+            UIGraphicsEndImageContext();
+        }else{
+            NSLog(@"%@",imgData);
+            newImg = [UIImage imageWithData:imgData];
+        }
+    }else{
+        onError = YES;
+    }
+    dispatch_group_leave(disG);
+    
+    
+    dispatch_group_notify(disG, dispatch_get_main_queue(), ^{
+        if(!onError) [imageView setImage:newImg];
+        NSLog(@"123");
+        if(needSave){
+//            [UIImageJPEGRepresentation(newImg, 1.0) writeToFile:filePath options:nil error:&error atomically:YES];
+            NSFileManager *fs = [NSFileManager defaultManager];
+            BOOL isDir;
+            [fs fileExistsAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"/Library/Caches"] isDirectory:&isDir];
+            NSLog(@"%@",isDir);
+            NSError *err;
+            [UIImageJPEGRepresentation(newImg, 1.0) writeToFile:filePath options:NSDataWritingAtomic error:&err];
+            NSLog(@"%@",err);
+        }
+    });
+    return filePath;
+}
+@end

+ 4 - 1
TumblrDownloader/TasksViewController.h

@@ -8,6 +8,9 @@
 
 #import <UIKit/UIKit.h>
 
-@interface TasksViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate>
+@interface TasksViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate,UIAlertViewDelegate>
 @property (strong, nonatomic) IBOutlet UITableView *TaskTableView;
+- (IBAction)EditTaskList:(id)sender;
+@property (strong, nonatomic) IBOutlet UIBarButtonItem *AllEditBtn;
+- (IBAction)EditAll:(id)sender;
 @end

+ 98 - 2
TumblrDownloader/TasksViewController.m

@@ -7,7 +7,7 @@
 //
 
 #import "TasksViewController.h"
-
+#import "ImageHandler.h"
 @interface TasksViewController ()
 @property NSUserDefaults *userDefaults;
 @property UIRefreshControl *uirefresh;
@@ -21,6 +21,7 @@
     // Do any additional setup after loading the view.
     _TaskTableView.delegate = self;
     _TaskTableView.dataSource = self;
+//    _TaskTableView sets
     _uirefresh = [[UIRefreshControl alloc]init];
     _uirefresh.attributedTitle = [[NSAttributedString alloc]initWithString:NSLocalizedString(@"PullToRefresh", nil)];
     [_TaskTableView addSubview:_uirefresh];
@@ -38,6 +39,10 @@
 -(void)viewDidAppear:(BOOL)animated{
     [self pullToRefresh];
 }
+-(void)updateSourceData{
+    [_userDefaults setObject:_TaskData forKey:@"tasks"];
+    [_userDefaults synchronize];
+}
 
 #pragma Table Refresh
 -(void)pullToRefresh{
@@ -63,7 +68,28 @@
 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
     UITableViewCell *cell = [_TaskTableView dequeueReusableCellWithIdentifier:@"TaskCellStyle"];
 //    cell.textLabel.
-    cell.textLabel.text = _TaskData[indexPath.row];
+    NSMutableDictionary *tumblrData = [NSMutableDictionary dictionaryWithDictionary:_TaskData[indexPath.row]];
+    NSLog(@"%@",[tumblrData objectForKey:@"imgURL"]);
+    NSString *newPath = [ImageHandler getAndSaveThumbImageFromURLandSetToImageView:[tumblrData objectForKey:@"imgURL"] saveToName:[tumblrData objectForKey:@"videoID"] setToImage:cell.imageView];
+//    NSLog(@"%@",newPath);
+//    dispatch_async(dispatch_get_main_queue(), ^{
+//        NSLog(@"%@",[tumblrData objectForKey:@"imgURL"]);
+//        UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[tumblrData objectForKey:@"imgURL"]]] scale:1];
+//        UIGraphicsBeginImageContext(CGSizeMake(80, 80));
+//        [img drawInRect:CGRectMake(0, 0, 80, 80)];
+//        UIImage *newImg = UIGraphicsGetImageFromCurrentImageContext();
+//        UIGraphicsEndImageContext();
+//        [cell.imageView setImage:newImg];
+//        NSString *jpgPath = [NSHomeDirectory() stringByAppendingString:[NSString stringWithFormat:@"/thumb/%@.jpg",[tumblrData objectForKey:@"videoID"]]];
+//        NSLog(@"%@",jpgPath);
+//        [UIImageJPEGRepresentation(newImg, 1.0) writeToFile:jpgPath atomically:YES];
+////        [cell.imageView setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[tumblrData objectForKey:@"imgURL"]]]]];
+//    });
+    
+    cell.textLabel.text = [tumblrData objectForKey:@"videoID"];
+    [tumblrData setObject:newPath forKey:@"cachePath"];
+    _TaskData[indexPath.row] = tumblrData;
+    [self updateSourceData];
     return cell;
 }
 
@@ -74,5 +100,75 @@
 -(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
     return 1;
 }
+-(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
+//    /UITableViewRowActionStyle *style =
+    UITableViewRowAction *downloadAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Download" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
+        
+    }];
+    downloadAction.backgroundColor = [UIColor colorWithRed:166/255.0 green:226/255.0 blue:105/255.0 alpha:1];
+    UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Delete" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
+        
+    }];
+    return @[deleteAction,downloadAction];
+}
+-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
+    return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert;
+}
+-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
+    [[_TaskTableView cellForRowAtIndexPath:indexPath] setTintColor:[UIColor redColor]];
+}
+-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
+    return 80;
+}
 
+#pragma Action
+- (IBAction)EditTaskList:(id)sender {
+    if([sender tag]==1){
+        [_TaskTableView setEditing:NO];
+        [sender setTitle:@"编辑"];
+        [_AllEditBtn setTitle:@"全部开始"];
+        [sender setTag:0];
+        [_AllEditBtn setTag:1];
+    }else{
+        [_TaskTableView setEditing:YES];
+        [sender setTitle:@"完成"];
+        [_AllEditBtn setTitle:@"删除"];
+        [sender setTag:1];
+        [_AllEditBtn setTag:2];
+    }
+}
+- (IBAction)EditAll:(id)sender {
+    if([sender tag]==2){
+        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"是否删除所有已选任务" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
+        [alert show];
+    }else{
+        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"所有任务加入下载队列" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
+        [alert show];
+    }
+}
+
+#pragma UIAlertView Delegate
+-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
+    if([_AllEditBtn tag]==2){
+        if(buttonIndex==1){
+//            NSArray *selectedIndexPaths =
+            [self deleteSelected:[_TaskTableView indexPathsForSelectedRows]];
+        }
+    }else{
+    
+    }
+}
+-(void)startAll{
+
+}
+-(void)deleteSelected:(NSArray *)indexPathsArray{
+    NSMutableIndexSet *indexSets = [[NSMutableIndexSet alloc]init];
+    [indexPathsArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+        NSIndexPath *index = (NSIndexPath *)obj;
+        [indexSets addIndex:index.row];
+    }];
+    [_TaskData removeObjectsAtIndexes:indexSets];
+    [self updateSourceData];
+    [self reloadCellData];
+}
 @end

+ 14 - 0
TumblrDownloader/TumblrData.h

@@ -0,0 +1,14 @@
+//
+//  TumblrData.h
+//  TumblrDownloader
+//
+//  Created by HonorLee on 16/1/21.
+//  Copyright © 2016年 HonorLee. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface TumblrData : NSObject
+@property NSString *videoID;
+@property NSString *previewImgURL;
+@end

+ 14 - 0
TumblrDownloader/TumblrData.m

@@ -0,0 +1,14 @@
+//
+//  TumblrData.m
+//  TumblrDownloader
+//
+//  Created by HonorLee on 16/1/21.
+//  Copyright © 2016年 HonorLee. All rights reserved.
+//
+
+#import "TumblrData.h"
+
+@implementation TumblrData
+@synthesize videoID;
+@synthesize previewImgURL;
+@end