1 |
|
|
2 |
|
package pl.magot.vetch.ancal.reminder; |
3 |
|
|
4 |
|
|
5 |
|
import pl.magot.vetch.ancal.R; |
6 |
|
import pl.magot.vetch.ancal.Utils; |
7 |
|
|
8 |
|
|
|
|
| 77,8% |
Uncovered Elements: 22 (99) |
Complexity: 25 |
Complexity Density: 0,39 |
|
9 |
|
public class AlarmDataViewItem |
10 |
|
{ |
11 |
|
|
12 |
|
public static final int iOrderAppts = 0; |
13 |
|
public static final int iOrderTasks = 1; |
14 |
|
|
15 |
|
|
16 |
|
private long lID = -1; |
17 |
|
protected String sSubject = ""; |
18 |
|
private int iOrder = -1; |
19 |
|
private int iHour = 0; |
20 |
|
private int iMinute = 0; |
21 |
|
private int iDurationInMinutes = 0; |
22 |
|
protected boolean bAlarm = false; |
23 |
|
protected long lPriority = -1; |
24 |
|
private long lRepeatDaysBitMask = 0; |
25 |
|
|
26 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
27 |
15
|
public AlarmDataViewItem(long lID, String sSubject, int iOrder, boolean bAlarm)... |
28 |
|
{ |
29 |
15
|
this.lID = lID; |
30 |
15
|
this.sSubject = sSubject; |
31 |
15
|
this.iOrder = iOrder; |
32 |
15
|
this.bAlarm = bAlarm; |
33 |
|
} |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
35 |
9
|
public void Set(int iHour, int iMinute, int iDurationInMinutes)... |
36 |
|
{ |
37 |
9
|
this.iHour = iHour; |
38 |
9
|
this.iMinute = iMinute; |
39 |
9
|
this.iDurationInMinutes = iDurationInMinutes; |
40 |
|
} |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
6
|
public void Set(long lPriority)... |
43 |
|
{ |
44 |
6
|
this.lPriority = lPriority; |
45 |
|
} |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
4
|
public int TimeAsSeconds()... |
48 |
|
{ |
49 |
4
|
return (iMinute * 60) + (iHour * 3600); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
9
|
public long GetID()... |
53 |
|
{ |
54 |
9
|
return lID; |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
48
|
public int GetOrder()... |
58 |
|
{ |
59 |
48
|
return this.iOrder; |
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
0
|
public int GetDuration()... |
63 |
|
{ |
64 |
0
|
return iDurationInMinutes; |
65 |
|
} |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
9
|
public void SetRepeatDays(long lDaysData)... |
68 |
|
{ |
69 |
9
|
lRepeatDaysBitMask = lDaysData; |
70 |
|
} |
71 |
|
|
72 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
73 |
0
|
public boolean GetVisibleDay(int iDay)... |
74 |
|
{ |
75 |
0
|
long bitMask = 0x01L << iDay; |
76 |
0
|
return ((lRepeatDaysBitMask & bitMask) != 0); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0,5 |
|
79 |
9
|
public int GetOverdueDays()... |
80 |
|
{ |
81 |
9
|
long bitMask = 0x01L; |
82 |
37
|
for (int iDayOffset = 0; iDayOffset < 7; iDayOffset++) |
83 |
|
{ |
84 |
33
|
if ((lRepeatDaysBitMask & bitMask) == bitMask) |
85 |
5
|
return iDayOffset; |
86 |
28
|
bitMask <<= 1; |
87 |
|
} |
88 |
4
|
return 0; |
89 |
|
} |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
91 |
4
|
public boolean IsOverdue()... |
92 |
|
{ |
93 |
4
|
long bitMask = 0x01L; |
94 |
4
|
return ((lRepeatDaysBitMask & bitMask) == 0); |
95 |
|
} |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
0
|
public int GetTimeKey()... |
98 |
|
{ |
99 |
0
|
return (iHour * 100) + iMinute; |
100 |
|
} |
101 |
|
|
|
|
| 66,7% |
Uncovered Elements: 7 (21) |
Complexity: 5 |
Complexity Density: 0,38 |
|
102 |
5
|
public String GetTimeAsText(boolean b24HourMode)... |
103 |
|
{ |
104 |
5
|
String s = ""; |
105 |
5
|
String sm = "AM"; |
106 |
5
|
if (iHour >= 12) |
107 |
0
|
sm = "PM"; |
108 |
5
|
int iDisplayHour = iHour; |
109 |
5
|
if (iDisplayHour == 0) |
110 |
5
|
iDisplayHour = 12; |
111 |
5
|
if (iDisplayHour > 12) |
112 |
0
|
iDisplayHour -= 12; |
113 |
|
|
114 |
5
|
if (b24HourMode) |
115 |
|
{ |
116 |
0
|
s = String.format("%1$d:%2$02d", iHour, iMinute); |
117 |
|
} else { |
118 |
5
|
s = String.format("%1$d:%2$02d %3$s", iDisplayHour, iMinute, sm); |
119 |
|
} |
120 |
5
|
return s; |
121 |
|
} |
122 |
|
|
|
|
| 68% |
Uncovered Elements: 8 (25) |
Complexity: 5 |
Complexity Density: 0,29 |
|
123 |
9
|
public String GetText(Utils utils, boolean b24HourMode)... |
124 |
|
{ |
125 |
9
|
final int iOverdueDays = GetOverdueDays(); |
126 |
9
|
String s = ""; |
127 |
|
|
128 |
9
|
String sText = new String(sSubject); |
129 |
9
|
sText = sText.replace("\n", " "); |
130 |
9
|
sText = Utils.CapitalizeFirstLetter(sText); |
131 |
|
|
132 |
|
|
133 |
9
|
if (iOrder == iOrderAppts) |
134 |
|
{ |
135 |
5
|
if (iOverdueDays == 0) |
136 |
|
{ |
137 |
5
|
String sTime = GetTimeAsText(b24HourMode); |
138 |
5
|
s = String.format("%1$s. %2$s", sTime, sText); |
139 |
|
} else { |
140 |
0
|
String sOverdueText = utils.GetResStr(R.string.msgDaysOverdue); |
141 |
0
|
s = String.format("%1$s. (%2$d %3$s)", sText, iOverdueDays, sOverdueText); |
142 |
0
|
if (iOverdueDays == 1) |
143 |
|
{ |
144 |
0
|
sOverdueText = utils.GetResStr(R.string.msgDayOverdue); |
145 |
0
|
s = String.format("%1$s. (%2$s)", sText, sOverdueText); |
146 |
|
} |
147 |
|
} |
148 |
|
} |
149 |
|
|
150 |
|
|
151 |
9
|
if (iOrder == iOrderTasks) |
152 |
|
{ |
153 |
4
|
s = String.format("%2$s. (%1$d)", lPriority, sText); |
154 |
|
} |
155 |
|
|
156 |
9
|
return s; |
157 |
|
} |
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
|
159 |
15
|
public String GetHashString()... |
160 |
|
{ |
161 |
15
|
String s = ""; |
162 |
15
|
s += Long.toString(lID); |
163 |
15
|
s += sSubject; |
164 |
15
|
s += Integer.toString(iOrder); |
165 |
15
|
s += Integer.toString(iHour); |
166 |
15
|
s += Integer.toString(iMinute); |
167 |
15
|
s += Boolean.toString(bAlarm); |
168 |
15
|
s += Long.toString(lPriority); |
169 |
15
|
s += Long.toString(lRepeatDaysBitMask); |
170 |
15
|
return s; |
171 |
|
} |
172 |
|
|
173 |
|
} |