1 |
|
|
2 |
|
package pl.magot.vetch.ancal.views; |
3 |
|
|
4 |
|
|
5 |
|
import android.content.Context; |
6 |
|
import android.util.AttributeSet; |
7 |
|
import android.widget.Button; |
8 |
|
import android.graphics.*; |
9 |
|
import android.graphics.drawable.Drawable; |
10 |
|
|
11 |
|
|
|
|
| 83,3% |
Uncovered Elements: 3 (18) |
Complexity: 5 |
Complexity Density: 0,42 |
|
12 |
|
public class ViewImgButton extends Button |
13 |
|
{ |
14 |
|
protected Drawable icon = null; |
15 |
|
private int iMarginX = 0; |
16 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
17 |
0
|
public ViewImgButton(Context context)... |
18 |
|
{ |
19 |
0
|
super(context); |
20 |
|
} |
21 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
22 |
2
|
@SuppressWarnings("all")... |
23 |
|
public ViewImgButton(Context context, AttributeSet attrs) |
24 |
|
{ |
25 |
2
|
super(context, attrs); |
26 |
|
} |
27 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0,25 |
|
28 |
303
|
@Override... |
29 |
|
protected void onDraw(Canvas canvas) |
30 |
|
{ |
31 |
303
|
super.onDraw(canvas); |
32 |
303
|
if (icon != null) |
33 |
|
{ |
34 |
303
|
int iW = icon.getMinimumWidth(); |
35 |
303
|
int iH = icon.getMinimumHeight(); |
36 |
|
|
37 |
303
|
int iX = (getWidth() >> 1) - (iW >> 1) + iMarginX; |
38 |
303
|
int iY = ((getHeight() - getPaddingTop()) >> 1) - (iH >> 1); |
39 |
|
|
40 |
303
|
icon.setBounds(iX, iY, iX + iW, iY + iH); |
41 |
303
|
icon.draw(canvas); |
42 |
|
} |
43 |
|
} |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
45 |
2
|
public void SetButtonIcon(int iResId, int iMarginX)... |
46 |
|
{ |
47 |
2
|
icon = getResources().getDrawable(iResId); |
48 |
2
|
this.iMarginX = iMarginX; |
49 |
|
} |
50 |
|
|
51 |
|
} |