summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/base/views/SimpleCheckBox.java
blob: 7cd790dbe1206ce48e30006272e0c0f38c4c75eb (plain)
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
package se.leap.bitmaskclient.base.views;

import android.annotation.TargetApi;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;

import androidx.appcompat.widget.AppCompatImageView;

import se.leap.bitmaskclient.R;

public class SimpleCheckBox extends RelativeLayout {

    AppCompatImageView checkView;


    public SimpleCheckBox(Context context) {
        super(context);
        initLayout(context);
    }

    public SimpleCheckBox(Context context, AttributeSet attrs) {
        super(context, attrs);
        initLayout(context);
    }

    public SimpleCheckBox(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initLayout(context);
    }

    @TargetApi(21)
    public SimpleCheckBox(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initLayout(context);
    }

    private void initLayout(Context context) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rootview = inflater.inflate(R.layout.v_simple_checkbox, this, true);
        this.checkView = rootview.findViewById(R.id.check_view);
    }

    public void setChecked(boolean checked) {
        this.checkView.setVisibility(checked ? VISIBLE : INVISIBLE);
    }
}