1 |
|
package pl.magot.vetch.widgets; |
2 |
|
|
3 |
|
import java.util.*; |
4 |
|
import android.app.*; |
5 |
|
import android.content.Intent; |
6 |
|
import android.os.Bundle; |
7 |
|
import android.widget.*; |
8 |
|
import android.view.*; |
9 |
|
import android.widget.Button; |
10 |
|
import android.widget.LinearLayout; |
11 |
|
import android.widget.LinearLayout.LayoutParams; |
12 |
|
import java.text.SimpleDateFormat; |
13 |
|
|
|
|
| 93,3% |
Uncovered Elements: 21 (312) |
Complexity: 62 |
Complexity Density: 0,28 |
|
14 |
|
public class DateWidget extends Activity { |
15 |
|
|
16 |
|
private static String sStrSelect = "Select day"; |
17 |
|
private static String sStrSelected = "Selected day:"; |
18 |
|
private static String sStrNone = "none"; |
19 |
|
|
20 |
|
|
21 |
|
private ArrayList<DateWidgetDayCell> days = new ArrayList<DateWidgetDayCell>(); |
22 |
|
|
23 |
|
|
24 |
|
private SimpleDateFormat dateMonth = new SimpleDateFormat("MMMM yyyy"); |
25 |
|
private SimpleDateFormat dateFull = new SimpleDateFormat("d MMMM yyyy"); |
26 |
|
|
27 |
|
|
28 |
|
private Calendar calStartDate = Calendar.getInstance(); |
29 |
|
private Calendar calToday = Calendar.getInstance(); |
30 |
|
private Calendar calCalendar = Calendar.getInstance(); |
31 |
|
private Calendar calSelected = Calendar.getInstance(); |
32 |
|
|
33 |
|
|
34 |
|
LinearLayout layContent = null; |
35 |
|
Button btnPrev = null; |
36 |
|
Button btnToday = null; |
37 |
|
Button btnNext = null; |
38 |
|
Button btnNone = null; |
39 |
|
|
40 |
|
|
41 |
|
private boolean bNoneButton = true; |
42 |
|
private int iFirstDayOfWeek = Calendar.MONDAY; |
43 |
|
|
44 |
|
|
45 |
|
private int iMonthViewCurrentMonth = 0; |
46 |
|
private int iMonthViewCurrentYear = 0; |
47 |
|
|
48 |
|
|
49 |
|
public static final int SELECT_DATE_REQUEST = 111; |
50 |
|
private static final int iDayCellSize = 38; |
51 |
|
private static final int iDayHeaderHeight = 24; |
52 |
|
private static final int iTotalWidth = (iDayCellSize * 7); |
53 |
|
private static final int iSmallButtonWidth = 100; |
54 |
|
|
55 |
|
|
|
|
| 88,9% |
Uncovered Elements: 4 (36) |
Complexity: 7 |
Complexity Density: 0,29 |
|
56 |
6
|
@Override... |
57 |
|
public void onCreate(Bundle icicle) { |
58 |
|
|
59 |
6
|
super.onCreate(icicle); |
60 |
|
|
61 |
|
|
62 |
6
|
calSelected.setTimeInMillis(0); |
63 |
6
|
iFirstDayOfWeek = Calendar.MONDAY; |
64 |
6
|
bNoneButton = true; |
65 |
|
|
66 |
|
|
67 |
6
|
Bundle data = this.getIntent().getExtras(); |
68 |
6
|
if (data != null) { |
69 |
6
|
if (data.containsKey("date")) |
70 |
6
|
calSelected.setTimeInMillis(data.getLong("date")); |
71 |
6
|
if (data.containsKey("firstDayOfWeek")) |
72 |
6
|
iFirstDayOfWeek = data.getInt("firstDayOfWeek"); |
73 |
6
|
if (data.containsKey("noneButton")) |
74 |
6
|
bNoneButton = data.getBoolean("noneButton"); |
75 |
|
} |
76 |
|
|
77 |
6
|
setContentView(generateContentView()); |
78 |
|
|
79 |
|
|
80 |
6
|
calStartDate = getCalendarStartDate(); |
81 |
6
|
DateWidgetDayCell daySelected = updateCalendar(); |
82 |
6
|
updateControlsState(); |
83 |
|
|
84 |
|
|
85 |
6
|
if (bNoneButton) { |
86 |
4
|
btnNone.requestFocus(); |
87 |
4
|
btnNone.setEnabled(true); |
88 |
4
|
btnNone.setFocusable(true); |
89 |
|
} else { |
90 |
2
|
btnNone.setEnabled(false); |
91 |
2
|
btnNone.setFocusable(false); |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
6
|
if (daySelected != null) |
96 |
3
|
daySelected.requestFocus(); |
97 |
|
} |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
99 |
6
|
@Override... |
100 |
|
public void onStart() { |
101 |
6
|
super.onStart(); |
102 |
|
|
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
105 |
1
|
public static void setStrings(String strSelect, String strSelected, String strNone) {... |
106 |
1
|
sStrSelect = new String(strSelect); |
107 |
1
|
sStrSelected = new String(strSelected); |
108 |
1
|
sStrNone = new String(strNone); |
109 |
|
} |
110 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
|
111 |
6
|
public static void Open(Activity parentActivity, boolean bNoneButton, final Calendar calDate, int iFirstDayOfWeek) {... |
112 |
6
|
Intent it = new Intent("android.intent.action.AnCal.ACTION_MODE_EDIT_SELECT_DATE"); |
113 |
6
|
Bundle data = new Bundle(); |
114 |
6
|
data.putLong("date", calDate.getTimeInMillis()); |
115 |
6
|
data.putInt("firstDayOfWeek", iFirstDayOfWeek); |
116 |
6
|
data.putBoolean("noneButton", bNoneButton); |
117 |
6
|
it.putExtras(data); |
118 |
6
|
parentActivity.startActivityForResult(it, SELECT_DATE_REQUEST); |
119 |
|
} |
120 |
|
|
|
|
| 71,4% |
Uncovered Elements: 6 (21) |
Complexity: 5 |
Complexity Density: 0,38 |
|
121 |
6
|
public static long GetSelectedDateOnActivityResult(int requestCode, int resultCode, Bundle extras, Calendar outDate) {... |
122 |
6
|
if (requestCode == DateWidget.SELECT_DATE_REQUEST) { |
123 |
6
|
if (resultCode == RESULT_OK) { |
124 |
6
|
if (extras.containsKey("date")) { |
125 |
6
|
final long lDate = extras.getLong("date"); |
126 |
|
|
127 |
6
|
if (lDate == 0) { |
128 |
0
|
outDate.setTimeInMillis(0); |
129 |
|
} else { |
130 |
6
|
Calendar calSelected = Calendar.getInstance(); |
131 |
6
|
calSelected.setTimeInMillis(lDate); |
132 |
6
|
outDate.set(Calendar.YEAR, calSelected.get(Calendar.YEAR)); |
133 |
6
|
outDate.set(Calendar.MONTH, calSelected.get(Calendar.MONTH)); |
134 |
6
|
outDate.set(Calendar.DAY_OF_MONTH, calSelected.get(Calendar.DAY_OF_MONTH)); |
135 |
|
} |
136 |
|
|
137 |
6
|
return lDate; |
138 |
|
} |
139 |
|
} |
140 |
|
} |
141 |
0
|
return -1; |
142 |
|
} |
143 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
144 |
78
|
public LinearLayout createLayout(int iOrientation) {... |
145 |
78
|
LinearLayout lay = new LinearLayout(this); |
146 |
78
|
lay.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, |
147 |
|
android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); |
148 |
78
|
lay.setOrientation(iOrientation); |
149 |
78
|
return lay; |
150 |
|
} |
151 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
152 |
12
|
public Button createButton(String sText, int iWidth, int iHeight) {... |
153 |
12
|
Button btn = new Button(this); |
154 |
12
|
btn.setText(sText); |
155 |
12
|
btn.setLayoutParams(new LayoutParams(iWidth, iHeight)); |
156 |
12
|
return btn; |
157 |
|
} |
158 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
159 |
0
|
public TextView createLabel(String sText, int iWidth, int iHeight) {... |
160 |
0
|
TextView label = new TextView(this); |
161 |
0
|
label.setText(sText); |
162 |
0
|
label.setLayoutParams(new LayoutParams(iWidth, iHeight)); |
163 |
0
|
return label; |
164 |
|
} |
165 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0,06 |
|
166 |
6
|
public void generateTopButtons(LinearLayout layTopControls) {... |
167 |
6
|
final int iHorPadding = 24; |
168 |
6
|
final int iSmallButtonWidth = 60; |
169 |
|
|
170 |
|
|
171 |
6
|
btnToday = createButton("", iTotalWidth - iSmallButtonWidth - iSmallButtonWidth, |
172 |
|
android.view.ViewGroup.LayoutParams.WRAP_CONTENT); |
173 |
6
|
btnToday.setPadding(iHorPadding, btnToday.getPaddingTop(), iHorPadding, btnToday.getPaddingBottom()); |
174 |
6
|
btnToday.setBackgroundResource(android.R.drawable.btn_default_small); |
175 |
|
|
176 |
6
|
SymbolButton btnPrev = new SymbolButton(this, SymbolButton.symbol.arrowLeft); |
177 |
6
|
btnPrev.setLayoutParams(new LayoutParams(iSmallButtonWidth, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); |
178 |
6
|
btnPrev.setBackgroundResource(android.R.drawable.btn_default_small); |
179 |
|
|
180 |
6
|
SymbolButton btnNext = new SymbolButton(this, SymbolButton.symbol.arrowRight); |
181 |
6
|
btnNext.setLayoutParams(new LayoutParams(iSmallButtonWidth, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); |
182 |
6
|
btnNext.setBackgroundResource(android.R.drawable.btn_default_small); |
183 |
|
|
184 |
|
|
185 |
6
|
btnPrev.setOnClickListener(new Button.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
186 |
5
|
public void onClick(View arg0) {... |
187 |
5
|
setPrevViewItem(); |
188 |
|
} |
189 |
|
}); |
190 |
6
|
btnToday.setOnClickListener(new Button.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
191 |
1
|
public void onClick(View arg0) {... |
192 |
1
|
setTodayViewItem(); |
193 |
|
} |
194 |
|
}); |
195 |
6
|
btnNext.setOnClickListener(new Button.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
196 |
25
|
public void onClick(View arg0) {... |
197 |
25
|
setNextViewItem(); |
198 |
|
} |
199 |
|
}); |
200 |
|
|
201 |
6
|
layTopControls.setGravity(Gravity.CENTER_HORIZONTAL); |
202 |
6
|
layTopControls.addView(btnPrev); |
203 |
6
|
layTopControls.addView(btnToday); |
204 |
6
|
layTopControls.addView(btnNext); |
205 |
|
} |
206 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
207 |
6
|
public void generateBottomButtons(LinearLayout layBottomControls) {... |
208 |
6
|
btnNone = createButton(sStrNone, iSmallButtonWidth, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); |
209 |
6
|
btnNone.setBackgroundResource(android.R.drawable.btn_default_small); |
210 |
|
|
211 |
|
|
212 |
6
|
btnNone.setOnClickListener(new Button.OnClickListener() { |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
213 |
0
|
public void onClick(View arg0) {... |
214 |
0
|
deselectAll(); |
215 |
0
|
updateControlsState(); |
216 |
0
|
OnClose(); |
217 |
|
} |
218 |
|
}); |
219 |
|
|
220 |
6
|
layBottomControls.setGravity(Gravity.CENTER_HORIZONTAL); |
221 |
6
|
layBottomControls.addView(btnNone); |
222 |
|
} |
223 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 2 |
Complexity Density: 0,1 |
|
224 |
6
|
private View generateContentView() {... |
225 |
6
|
LinearLayout layMain = createLayout(LinearLayout.VERTICAL); |
226 |
6
|
layMain.setPadding(8, 8, 8, 8); |
227 |
|
|
228 |
6
|
LinearLayout layTopControls = createLayout(LinearLayout.HORIZONTAL); |
229 |
6
|
LinearLayout layContentTop = createLayout(LinearLayout.HORIZONTAL); |
230 |
6
|
LinearLayout layContentBottom = createLayout(LinearLayout.HORIZONTAL); |
231 |
6
|
LinearLayout layBottomControls = createLayout(LinearLayout.HORIZONTAL); |
232 |
|
|
233 |
6
|
layContent = createLayout(LinearLayout.VERTICAL); |
234 |
6
|
layContent.setPadding(8, 0, 8, 0); |
235 |
|
|
236 |
6
|
generateTopButtons(layTopControls); |
237 |
6
|
generateBottomButtons(layBottomControls); |
238 |
|
|
239 |
6
|
layContentTop.getLayoutParams().height = 12; |
240 |
6
|
layContentBottom.getLayoutParams().height = 18; |
241 |
|
|
242 |
6
|
generateCalendar(layContent); |
243 |
|
|
244 |
6
|
if (!bNoneButton) |
245 |
2
|
layBottomControls.getLayoutParams().height = 0; |
246 |
|
|
247 |
6
|
layMain.addView(layTopControls); |
248 |
6
|
layMain.addView(layContentTop); |
249 |
6
|
layMain.addView(layContent); |
250 |
6
|
layMain.addView(layContentBottom); |
251 |
6
|
layMain.addView(layBottomControls); |
252 |
|
|
253 |
6
|
return layMain; |
254 |
|
} |
255 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0,29 |
|
256 |
36
|
private View generateCalendarRow() {... |
257 |
36
|
LinearLayout layRow = createLayout(LinearLayout.HORIZONTAL); |
258 |
288
|
for (int iDay = 0; iDay < 7; iDay++) { |
259 |
252
|
DateWidgetDayCell dayCell = new DateWidgetDayCell(this, iDayCellSize, iDayCellSize); |
260 |
252
|
dayCell.setItemClick(mOnDayCellClick); |
261 |
252
|
days.add(dayCell); |
262 |
252
|
layRow.addView(dayCell); |
263 |
|
} |
264 |
36
|
return layRow; |
265 |
|
} |
266 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0,33 |
|
267 |
6
|
private View generateCalendarHeader() {... |
268 |
6
|
LinearLayout layRow = createLayout(LinearLayout.HORIZONTAL); |
269 |
48
|
for (int day = 0; day < 7; day++) { |
270 |
42
|
DateWidgetDayHeader header = new DateWidgetDayHeader(this, iDayCellSize, iDayHeaderHeight); |
271 |
42
|
header.setData((day + iFirstDayOfWeek) % 7); |
272 |
42
|
layRow.addView(header); |
273 |
|
} |
274 |
6
|
return layRow; |
275 |
|
} |
276 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
277 |
6
|
private void generateCalendar(LinearLayout layContent) {... |
278 |
|
|
279 |
6
|
layContent.addView(generateCalendarHeader()); |
280 |
|
|
281 |
6
|
days.clear(); |
282 |
42
|
for (int iRow = 0; iRow < 6; iRow++) { |
283 |
36
|
layContent.addView(generateCalendarRow()); |
284 |
|
} |
285 |
|
} |
286 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0,22 |
|
287 |
6
|
private Calendar getCalendarStartDate() {... |
288 |
6
|
calToday.setTimeInMillis(System.currentTimeMillis()); |
289 |
6
|
calToday.setFirstDayOfWeek(iFirstDayOfWeek); |
290 |
|
|
291 |
6
|
if (calSelected.getTimeInMillis() == 0) { |
292 |
3
|
calStartDate.setTimeInMillis(System.currentTimeMillis()); |
293 |
3
|
calStartDate.setFirstDayOfWeek(iFirstDayOfWeek); |
294 |
|
} else { |
295 |
3
|
calStartDate.setTimeInMillis(calSelected.getTimeInMillis()); |
296 |
3
|
calStartDate.setFirstDayOfWeek(iFirstDayOfWeek); |
297 |
|
} |
298 |
|
|
299 |
6
|
UpdateStartDateForMonth(); |
300 |
|
|
301 |
6
|
return calStartDate; |
302 |
|
} |
303 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (52) |
Complexity: 14 |
Complexity Density: 0,41 |
|
304 |
37
|
private DateWidgetDayCell updateCalendar() {... |
305 |
37
|
DateWidgetDayCell daySelected = null; |
306 |
37
|
boolean bSelected = false; |
307 |
|
|
308 |
37
|
final boolean bIsSelection = (calSelected.getTimeInMillis() != 0); |
309 |
37
|
final int iSelectedYear = calSelected.get(Calendar.YEAR); |
310 |
37
|
final int iSelectedMonth = calSelected.get(Calendar.MONTH); |
311 |
37
|
final int iSelectedDay = calSelected.get(Calendar.DAY_OF_MONTH); |
312 |
|
|
313 |
37
|
calCalendar.setTimeInMillis(calStartDate.getTimeInMillis()); |
314 |
|
|
315 |
1591
|
for (int i = 0; i < days.size(); i++) { |
316 |
1554
|
final int iYear = calCalendar.get(Calendar.YEAR); |
317 |
1554
|
final int iMonth = calCalendar.get(Calendar.MONTH); |
318 |
1554
|
final int iDay = calCalendar.get(Calendar.DAY_OF_MONTH); |
319 |
1554
|
final int iDayOfWeek = calCalendar.get(Calendar.DAY_OF_WEEK); |
320 |
|
|
321 |
1554
|
DateWidgetDayCell dayCell = days.get(i); |
322 |
|
|
323 |
|
|
324 |
1554
|
boolean bToday = false; |
325 |
1554
|
if (calToday.get(Calendar.YEAR) == iYear) |
326 |
277
|
if (calToday.get(Calendar.MONTH) == iMonth) |
327 |
242
|
if (calToday.get(Calendar.DAY_OF_MONTH) == iDay) |
328 |
7
|
bToday = true; |
329 |
|
|
330 |
|
|
331 |
1554
|
boolean bHoliday = false; |
332 |
1554
|
if ((iDayOfWeek == Calendar.SATURDAY) || (iDayOfWeek == Calendar.SUNDAY)) |
333 |
444
|
bHoliday = true; |
334 |
1554
|
if ((iMonth == Calendar.JANUARY) && (iDay == 1)) |
335 |
13
|
bHoliday = true; |
336 |
|
|
337 |
1554
|
dayCell.setData(iYear, iMonth, iDay, bToday, bHoliday, iMonthViewCurrentMonth); |
338 |
|
|
339 |
|
|
340 |
1554
|
bSelected = false; |
341 |
1554
|
if (bIsSelection) |
342 |
756
|
if ((iSelectedDay == iDay) && (iSelectedMonth == iMonth) && (iSelectedYear == iYear)) |
343 |
3
|
bSelected = true; |
344 |
|
|
345 |
1554
|
dayCell.setSelected(bSelected); |
346 |
1554
|
if (bSelected) |
347 |
3
|
daySelected = dayCell; |
348 |
|
|
349 |
1554
|
calCalendar.add(Calendar.DAY_OF_MONTH, 1); |
350 |
|
} |
351 |
|
|
352 |
37
|
layContent.invalidate(); |
353 |
37
|
return daySelected; |
354 |
|
} |
355 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
356 |
37
|
private void UpdateStartDateForMonth() {... |
357 |
37
|
iMonthViewCurrentMonth = calStartDate.get(Calendar.MONTH); |
358 |
37
|
iMonthViewCurrentYear = calStartDate.get(Calendar.YEAR); |
359 |
37
|
calStartDate.set(Calendar.DAY_OF_MONTH, 1); |
360 |
|
|
361 |
37
|
UpdateCurrentMonthDisplay(); |
362 |
37
|
int iDay = calStartDate.get(Calendar.DAY_OF_WEEK) - iFirstDayOfWeek; |
363 |
37
|
calStartDate.add(Calendar.DAY_OF_WEEK, -iDay); |
364 |
|
} |
365 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
366 |
37
|
private void UpdateCurrentMonthDisplay() {... |
367 |
37
|
String s = dateMonth.format(calStartDate.getTime()); |
368 |
37
|
btnToday.setText(s); |
369 |
|
} |
370 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0,22 |
|
371 |
5
|
public void setPrevViewItem() {... |
372 |
5
|
iMonthViewCurrentMonth--; |
373 |
5
|
if (iMonthViewCurrentMonth == -1) { |
374 |
1
|
iMonthViewCurrentMonth = 11; |
375 |
1
|
iMonthViewCurrentYear--; |
376 |
|
} |
377 |
5
|
calStartDate.set(Calendar.DAY_OF_MONTH, 1); |
378 |
5
|
calStartDate.set(Calendar.MONTH, iMonthViewCurrentMonth); |
379 |
5
|
calStartDate.set(Calendar.YEAR, iMonthViewCurrentYear); |
380 |
5
|
UpdateStartDateForMonth(); |
381 |
5
|
updateCalendar(); |
382 |
|
} |
383 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
384 |
1
|
public void setTodayViewItem() {... |
385 |
1
|
calToday.setTimeInMillis(System.currentTimeMillis()); |
386 |
1
|
calToday.setFirstDayOfWeek(iFirstDayOfWeek); |
387 |
|
|
388 |
1
|
calStartDate.setTimeInMillis(calToday.getTimeInMillis()); |
389 |
1
|
calStartDate.setFirstDayOfWeek(iFirstDayOfWeek); |
390 |
|
|
391 |
1
|
UpdateStartDateForMonth(); |
392 |
1
|
updateCalendar(); |
393 |
|
} |
394 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0,22 |
|
395 |
25
|
public void setNextViewItem() {... |
396 |
25
|
iMonthViewCurrentMonth++; |
397 |
25
|
if (iMonthViewCurrentMonth == 12) { |
398 |
5
|
iMonthViewCurrentMonth = 0; |
399 |
5
|
iMonthViewCurrentYear++; |
400 |
|
} |
401 |
25
|
calStartDate.set(Calendar.DAY_OF_MONTH, 1); |
402 |
25
|
calStartDate.set(Calendar.MONTH, iMonthViewCurrentMonth); |
403 |
25
|
calStartDate.set(Calendar.YEAR, iMonthViewCurrentYear); |
404 |
25
|
UpdateStartDateForMonth(); |
405 |
25
|
updateCalendar(); |
406 |
|
} |
407 |
|
|
408 |
|
public DateWidgetDayCell.OnItemClick mOnDayCellClick = new DateWidgetDayCell.OnItemClick() { |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
409 |
6
|
public void OnClick(DateWidgetDayCell item) {... |
410 |
6
|
deselectAll(); |
411 |
6
|
calSelected.setTimeInMillis(item.getDate().getTimeInMillis()); |
412 |
6
|
item.setSelected(true); |
413 |
6
|
updateControlsState(); |
414 |
6
|
OnClose(); |
415 |
|
} |
416 |
|
}; |
417 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0,33 |
|
418 |
12
|
public void updateControlsState() {... |
419 |
12
|
final boolean bDaySelected = (calSelected.getTimeInMillis() != 0); |
420 |
12
|
btnNone.setEnabled(bDaySelected); |
421 |
12
|
if (bDaySelected) { |
422 |
9
|
String s = dateFull.format(calSelected.getTime()); |
423 |
9
|
setTitle(sStrSelected + " " + s); |
424 |
|
} else { |
425 |
3
|
setTitle(sStrSelect); |
426 |
|
} |
427 |
|
} |
428 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 3 |
Complexity Density: 0,5 |
|
429 |
6
|
public void deselectAll() {... |
430 |
6
|
calSelected.setTimeInMillis(0); |
431 |
258
|
for (int i = 0; i < days.size(); i++) { |
432 |
252
|
DateWidgetDayCell dayCell = days.get(i); |
433 |
252
|
if (dayCell.getSelected()) |
434 |
0
|
dayCell.setSelected(false); |
435 |
|
} |
436 |
6
|
layContent.invalidate(); |
437 |
|
} |
438 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
439 |
6
|
public void OnClose() {... |
440 |
6
|
Bundle data = new Bundle(); |
441 |
6
|
data.putLong("date", calSelected.getTimeInMillis()); |
442 |
|
|
443 |
6
|
Intent intentData = new Intent(""); |
444 |
6
|
intentData.putExtras(data); |
445 |
6
|
setResult(RESULT_OK, intentData); |
446 |
|
|
447 |
6
|
this.finish(); |
448 |
|
} |
449 |
|
|
450 |
|
} |