DeteMin
2020-03-31 77c62e023d2dc31200fc696158df84b3aee90ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.basic.security.widget;
 
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
 
import com.basic.security.R;
import com.basic.security.base.BaseApplication;
 
public class FaceOuterBorderView extends View {
 
    public int borderColor1;
    int mlineWidth = R.dimen.h8;
    private Paint mPaint;
    private int lineLong;
 
    public FaceOuterBorderView(Context context) {
        super(context);
        init();
    }
 
    public FaceOuterBorderView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }
 
    public FaceOuterBorderView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }
 
    private void init() {
        setLayerType(LAYER_TYPE_SOFTWARE, null);
        mPaint = new Paint();
        mPaint.setColor(Color.parseColor("#74F8F5"));
        mPaint.setStrokeWidth(BaseApplication.getApplication().activity.getResources().getDimension(mlineWidth));
        lineLong = (int) BaseApplication.getApplication().activity.getResources().getDimension(R.dimen.h55);
    }
 
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int width = this.getWidth();
        int height = this.getHeight();
 
        // 上边
        canvas.drawLine(0, 0, lineLong, 0, mPaint);
        canvas.drawLine(width - lineLong, 0, width, 0, mPaint);
 
        // 右边
        canvas.drawLine(width, 0, width, lineLong, mPaint);
        canvas.drawLine(width, height - lineLong, width, height, mPaint);
 
        // 下边
        canvas.drawLine(width - lineLong, height, width, height, mPaint);
        canvas.drawLine(0, height, lineLong, height, mPaint);
 
        // 左边
        canvas.drawLine(0, 0, 0, lineLong, mPaint);
        canvas.drawLine(0, height - lineLong, 0, height, mPaint);
    }
 
    public void setLiveness(boolean liveness) {
        if (liveness) {
            mPaint.setColor(Color.parseColor("#74F8F5"));
        } else {
            mPaint.setColor(Color.parseColor("#FF0000"));
        }
    }
 
    public void setPaintColor(int color) {
        mPaint.setColor(color);
    }
 
    public void setLineLong(int lineLong) {
        this.lineLong = lineLong;
    }
 
    public void setBorderColor(int borderColor) {
        mPaint.setColor(borderColor);
    }
 
    public void setBorderColor1(int borderColor1) {
        this.borderColor1 = borderColor1;
    }
 
    public int getBorderColor1(){ return this.borderColor1; }
}