forked from peterhajas/MobileNotifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MNAlertTableViewDataSourceEditable.m
60 lines (48 loc) · 1.88 KB
/
MNAlertTableViewDataSourceEditable.m
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
#import "MNAlertTableViewDataSourceEditable.h"
@implementation MNAlertTableViewDataSourceEditable
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MNTableViewCell *cell = (MNTableViewCell *) [tableView dequeueReusableCellWithIdentifier:@"notificationTableCell"];
if (cell == nil)
{
cell = [[[MNTableViewCell alloc] init] autorelease];
}
MNAlertData *dataObj;
if(type == kMNAlertTableViewDataSourceTypePending)
{
dataObj = [[_delegate getPendingAlerts] objectAtIndex:indexPath.row];
}
else if(type == kMNAlertTableViewDataSourceTypeArchived)
{
dataObj = [[_delegate getDismissedAlerts] objectAtIndex:indexPath.row];
}
else
{
dataObj = [[[MNAlertData alloc] initWithHeader:@"Null"
withText:@"Null"
andType:kPushAlert
forBundleID:@"com.apple.calculator"
ofStatus:kNewAlertForeground]
autorelease];
}
cell.iconImageView.image = [_delegate iconForBundleID:dataObj.bundleID];
cell.headerLabel.text = dataObj.header;
cell.alertTextLabel.text = dataObj.text;
return cell;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
if (type == kMNAlertTableViewDataSourceTypePending)
{
// Dismiss the alert
[_delegate dismissedAlertAtIndex:indexPath.row];
}
// Delete row from tableview
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
// Reload data
[tableView reloadData];
}
}
@end