1 |
|
|
2 |
|
package pl.magot.vetch.widgets; |
3 |
|
|
4 |
|
|
5 |
|
import java.util.*; |
6 |
|
|
7 |
|
import pl.magot.vetch.ancal.AnCalDateUtils; |
8 |
|
import android.content.*; |
9 |
|
import android.view.*; |
10 |
|
import android.widget.LinearLayout.LayoutParams; |
11 |
|
import android.graphics.*; |
12 |
|
|
13 |
|
|
|
|
| 96,9% |
Uncovered Elements: 1 (32) |
Complexity: 8 |
Complexity Density: 0,35 |
|
14 |
|
public class DateWidgetDayHeader extends View |
15 |
|
{ |
16 |
|
|
17 |
|
private final static int iDayHeaderFontSize = 12; |
18 |
|
|
19 |
|
|
20 |
|
private Paint pt = new Paint(); |
21 |
|
private RectF rect = new RectF(); |
22 |
|
private int iWeekDay = -1; |
23 |
|
private boolean bHoliday = false; |
24 |
|
|
25 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
26 |
42
|
public DateWidgetDayHeader(Context context, int iWidth, int iHeight)... |
27 |
|
{ |
28 |
42
|
super(context); |
29 |
42
|
setLayoutParams(new LayoutParams(iWidth, iHeight)); |
30 |
|
} |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0,75 |
|
32 |
42
|
public void setData(int iWeekDay)... |
33 |
|
{ |
34 |
42
|
this.iWeekDay = iWeekDay; |
35 |
42
|
this.bHoliday = false; |
36 |
42
|
if ((iWeekDay == Calendar.SATURDAY) || (iWeekDay == Calendar.SUNDAY)) |
37 |
6
|
this.bHoliday = true; |
38 |
|
} |
39 |
|
|
|
|
| 92,9% |
Uncovered Elements: 1 (14) |
Complexity: 2 |
Complexity Density: 0,17 |
|
40 |
329
|
private void drawDayHeader(Canvas canvas)... |
41 |
|
{ |
42 |
329
|
if (iWeekDay != -1) |
43 |
|
{ |
44 |
|
|
45 |
329
|
pt.setColor(dayStyle.getColorFrameHeader(bHoliday)); |
46 |
329
|
canvas.drawRect(rect, pt); |
47 |
|
|
48 |
|
|
49 |
329
|
pt.setTypeface(null); |
50 |
329
|
pt.setTextSize(iDayHeaderFontSize); |
51 |
329
|
pt.setAntiAlias(true); |
52 |
329
|
pt.setFakeBoldText(true); |
53 |
329
|
pt.setColor(dayStyle.getColorTextHeader(bHoliday)); |
54 |
|
|
55 |
329
|
final int iTextPosY = getTextHeight(); |
56 |
329
|
final String sDayName = AnCalDateUtils.getAbbrevDayOfWeekString(iWeekDay); |
57 |
|
|
58 |
|
|
59 |
329
|
final int iDayNamePosX = (int)rect.left + ((int)rect.width() >> 1) - ((int)pt.measureText(sDayName) >> 1); |
60 |
329
|
canvas.drawText(sDayName, iDayNamePosX, rect.top + iTextPosY + 2, pt); |
61 |
|
} |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
329
|
private int getTextHeight()... |
65 |
|
{ |
66 |
329
|
return (int)(-pt.ascent() + pt.descent()); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
69 |
329
|
@Override... |
70 |
|
protected void onDraw(Canvas canvas) |
71 |
|
{ |
72 |
329
|
super.onDraw(canvas); |
73 |
|
|
74 |
|
|
75 |
329
|
rect.set(0, 0, this.getWidth(), this.getHeight()); |
76 |
329
|
rect.inset(1, 1); |
77 |
|
|
78 |
|
|
79 |
329
|
drawDayHeader(canvas); |
80 |
|
} |
81 |
|
|
82 |
|
} |