package com.tencent.liteav.demo.player.ui;

import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.tencent.liteav.demo.player.R;

public class CastScanning extends LinearLayout {
    private ImageView imgLoading;


    public CastScanning(Context context) {
        this(context, null);
    }

    public CastScanning(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CastScanning(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public CastScanning(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context, attrs, defStyleAttr, defStyleRes);
    }

    private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        LayoutInflater.from(context).inflate(R.layout.cast_scanning, this);

        imgLoading = findViewById(R.id.img_cast_scanning);

        Animation animation = AnimationUtils.loadAnimation(context, R.anim.rotate_loading);
        animation.setInterpolator(new LinearInterpolator());
        animation.setDuration(1200);
        animation.setRepeatCount(-1);
        animation.setRepeatMode(Animation.RESTART);
        imgLoading.startAnimation(animation);
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
    }
}
