1 |
|
|
2 |
|
package pl.magot.vetch.ancal.dataview; |
3 |
|
|
4 |
|
|
5 |
|
import java.util.*; |
6 |
|
|
7 |
|
import pl.magot.vetch.ancal.Prefs; |
8 |
|
import pl.magot.vetch.ancal.Utils; |
9 |
|
import pl.magot.vetch.ancal.agenda.AgendaViewType; |
10 |
|
import pl.magot.vetch.ancal.database.DataRowTask; |
11 |
|
import pl.magot.vetch.ancal.database.Database; |
12 |
|
import android.database.Cursor; |
13 |
|
|
14 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (51) |
Complexity: 14 |
Complexity Density: 0,5 |
|
15 |
|
public class DataViewTask extends DataView |
16 |
|
{ |
17 |
|
|
|
|
| 77,8% |
Uncovered Elements: 4 (18) |
Complexity: 4 |
Complexity Density: 0,36 |
|
18 |
|
public class RowsComparator implements Comparator<DataViewItem> |
19 |
|
{ |
|
|
| 76,5% |
Uncovered Elements: 4 (17) |
Complexity: 4 |
Complexity Density: 0,36 |
|
20 |
33
|
public int compare(DataViewItem item1, DataViewItem item2)... |
21 |
|
{ |
22 |
33
|
long iPriority1 = item1.lPriority; |
23 |
33
|
long iPriority2 = item2.lPriority; |
24 |
|
|
25 |
33
|
if (iPriority1 > iPriority2) |
26 |
5
|
return 1; |
27 |
28
|
if (iPriority1 < iPriority2) |
28 |
0
|
return -1; |
29 |
|
|
30 |
28
|
if (iPriority1 == iPriority2) |
31 |
|
{ |
32 |
28
|
String s1 = item1.sSubject; |
33 |
28
|
String s2 = item2.sSubject; |
34 |
28
|
return s1.compareTo(s2); |
35 |
|
} |
36 |
|
|
37 |
0
|
return 0; |
38 |
|
} |
39 |
|
}; |
40 |
|
|
41 |
|
|
42 |
|
private Calendar calDueDateCmp = Calendar.getInstance(); |
43 |
|
private RowsComparator fnCmp = null; |
44 |
|
|
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
46 |
2
|
public DataViewTask(Database db, Prefs prefs)... |
47 |
|
{ |
48 |
2
|
super(db, prefs); |
49 |
2
|
sTableName = Database.sTableNameTasks; |
50 |
2
|
fnCmp = new RowsComparator(); |
51 |
|
} |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0,22 |
|
53 |
57
|
@Override... |
54 |
|
public void AddItem(Cursor cr) |
55 |
|
{ |
56 |
57
|
DataViewItem item = new DataViewItem(); |
57 |
|
|
58 |
57
|
item.lID = cr.getLong(DataRowTask.fid.ID); |
59 |
57
|
item.sSubject = cr.getString(DataRowTask.fid.Subject); |
60 |
57
|
item.bDone = (cr.getLong(DataRowTask.fid.Done) == 1); |
61 |
57
|
item.lPriority = cr.getLong(DataRowTask.fid.Priority); |
62 |
57
|
item.bAlarm = (cr.getLong(DataRowTask.fid.Alarm) == 1); |
63 |
|
|
64 |
57
|
if (!cr.isNull(DataRowTask.fid.DueDate)) |
65 |
30
|
item.lDueDate = cr.getLong(DataRowTask.fid.DueDate); |
66 |
|
|
67 |
57
|
rows.add(item); |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 9 |
Complexity Density: 0,6 |
|
70 |
71
|
@Override... |
71 |
|
public void FilterDataForView(DataViewItem item, final Calendar calStartDate, final AgendaViewType agendaViewType) |
72 |
|
{ |
73 |
|
|
74 |
71
|
if (agendaViewType == AgendaViewType.TODAY) |
75 |
|
{ |
76 |
31
|
if (prefs.bShowAllTasks) |
77 |
|
{ |
78 |
13
|
item.viewMode = agendaViewType; |
79 |
|
} else { |
80 |
18
|
if (item.UseDueDate()) |
81 |
|
{ |
82 |
10
|
calDueDateCmp.setTimeInMillis(item.lDueDate); |
83 |
10
|
if (Utils.YearDaysEqual(calStartDate, calDueDateCmp)) |
84 |
9
|
item.viewMode = agendaViewType; |
85 |
|
} else { |
86 |
8
|
item.viewMode = agendaViewType; |
87 |
|
} |
88 |
|
} |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
71
|
if (agendaViewType == AgendaViewType.TODAY_ALARM) |
93 |
|
{ |
94 |
40
|
if (!item.bDone) |
95 |
|
{ |
96 |
13
|
if (item.UseDueDate()) |
97 |
|
{ |
98 |
6
|
calDueDateCmp.setTimeInMillis(item.lDueDate); |
99 |
6
|
if (Utils.YearDaysGreater(calStartDate, calDueDateCmp)) |
100 |
3
|
item.viewMode = agendaViewType; |
101 |
|
} else { |
102 |
7
|
item.viewMode = agendaViewType; |
103 |
|
} |
104 |
|
} |
105 |
|
} |
106 |
|
|
107 |
|
} |
108 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
109 |
55
|
@Override... |
110 |
|
protected void FilterDataPrepare(final Calendar calStartDate, final AgendaViewType agendaViewType) |
111 |
|
{ |
112 |
|
|
113 |
|
} |
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
38
|
@Override... |
116 |
|
public void SortView() |
117 |
|
{ |
118 |
38
|
Collections.sort(rows, fnCmp); |
119 |
|
} |
120 |
|
|
121 |
|
} |