|
@@ -48,13 +48,14 @@
|
|
|
-(void)pullToRefresh{
|
|
|
NSLog(@"Start refresh");
|
|
|
_uirefresh.attributedTitle = [[NSAttributedString alloc]initWithString:NSLocalizedString(@"PullToRefreshing", nil)];
|
|
|
+ [_uirefresh beginRefreshing];
|
|
|
[self reloadCellData];
|
|
|
[self refreshEnd];
|
|
|
}
|
|
|
|
|
|
-(void)refreshEnd{
|
|
|
- [_uirefresh endRefreshing];
|
|
|
_uirefresh.attributedTitle = [[NSAttributedString alloc]initWithString:NSLocalizedString(@"PullToRefreshEnd", nil)];
|
|
|
+ [_uirefresh endRefreshing];
|
|
|
}
|
|
|
|
|
|
-(void)reloadCellData{
|
|
@@ -100,17 +101,17 @@
|
|
|
-(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];
|
|
|
-}
|
|
|
+//-(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;
|
|
|
}
|
|
@@ -118,7 +119,7 @@
|
|
|
[[_TaskTableView cellForRowAtIndexPath:indexPath] setTintColor:[UIColor redColor]];
|
|
|
}
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
- return 80;
|
|
|
+ return 60;
|
|
|
}
|
|
|
|
|
|
#pragma Action
|
|
@@ -163,12 +164,24 @@
|
|
|
}
|
|
|
-(void)deleteSelected:(NSArray *)indexPathsArray{
|
|
|
NSMutableIndexSet *indexSets = [[NSMutableIndexSet alloc]init];
|
|
|
+ NSFileManager *fs = [NSFileManager defaultManager];
|
|
|
[indexPathsArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
NSIndexPath *index = (NSIndexPath *)obj;
|
|
|
[indexSets addIndex:index.row];
|
|
|
+ NSDictionary *tumblrData = [NSDictionary dictionaryWithDictionary:_TaskData[index.row]];
|
|
|
+ NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"/Library/Caches/%@.jpg",[tumblrData objectForKey:@"videoID"]]];
|
|
|
+ if([fs fileExistsAtPath:filePath]){
|
|
|
+ NSLog(@"Remove cache");
|
|
|
+ NSError *err;
|
|
|
+ [fs removeItemAtPath:filePath error:&err];
|
|
|
+ NSLog(@"Remove error:%@",err);
|
|
|
+ }
|
|
|
}];
|
|
|
[_TaskData removeObjectsAtIndexes:indexSets];
|
|
|
+// [_TaskTableView setContentOffset:CGPointMake(0, -200) animated:NO];
|
|
|
+#pragma reload
|
|
|
[self updateSourceData];
|
|
|
+// [_uirefresh sendActionsForControlEvents:UIControlEventValueChanged];
|
|
|
[self reloadCellData];
|
|
|
}
|
|
|
@end
|