summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/base/views/ProgressSpinner.java
blob: b0b81624cd06408e42f4b3a3c7e9e7f384a05c7f (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
51
52
53
package se.leap.bitmaskclient.base.views;

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

import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.ContextCompat;

import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.databinding.VProgressSpinnerBinding;

public class ProgressSpinner extends RelativeLayout {

    private static final String TAG = ProgressSpinner.class.getSimpleName();

    AppCompatImageView spinnerView;
    AppCompatTextView textView;

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

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

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


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

    private void initLayout(Context context) {
        VProgressSpinnerBinding binding = VProgressSpinnerBinding.inflate(LayoutInflater.from(context), this, true);
        spinnerView = binding.spinnerView;
        textView = binding.tvProgress;
    }

    public void update(int progress) {
        textView.setText(textView.getContext().getString(R.string.percentage, progress));
    }
}