Repository navigation
Expand file tree
/
Copy pathSMNoteMemoAdapter.m
More file actions
67 lines (51 loc) · 2.06 KB
/
Copy pathSMNoteMemoAdapter.m
File metadata and controls
67 lines (51 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// SMNoteMemoAdapter.m
// SMNote
//
// Created by SimonMiao on 16/8/11.
// Copyright © 2016年 MSY. All rights reserved.
//
#import "SMNoteMemoAdapter.h"
#import "SMNoteMemoCell.h"
#import "SMNoteDetailModel.h"
#import "SMDaoFactory.h"
@implementation SMNoteMemoAdapter
- (NSMutableArray *)deleteArray {
if (!_deleteArray) {
_deleteArray = [NSMutableArray arrayWithCapacity:0];
}
return _deleteArray;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForSMNoteDetailModel:(id)cellData {
NSString *cellId = NSStringFromSelector(_cmd);
SMNoteMemoCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) {
cell = [[SMNoteMemoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
[cell updateCellWithData:cellData hideHeaderLine:YES hideFooterLine:NO];
return cell;
}
#pragma mark - UITableViewDatasource
//- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// return YES;
//}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
id cellData = self.adapterArray[indexPath.row];
if ([cellData isKindOfClass:[SMNoteDetailModel class]]) {
SMNoteDetailModel *model = (SMNoteDetailModel *)cellData;
[self.adapterArray removeObject:model];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationRight];
[[_Dao getMemoDao] removeMemos:@[model] async:YES];
}
}
}
#pragma mark - UITableViewDelegate
//- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
// return UITableViewCellEditingStyleDelete;
//}
@end