package com.fun.wave.pranksounds.activity;

import android.content.Intent;
import android.os.CountDownTimer;

import com.fun.wave.pranksounds.base.BaseActivity;
import com.fun.wave.pranksounds.databinding.WelActivityBinding;

public class WelActivity extends BaseActivity<WelActivityBinding> {

    private CountDownTimer countDownTimer;
    @Override
    protected void init() {
        long time = 1200;
        countDownTimer = new CountDownTimer(time, 50) {
            @Override
            public void onFinish() {
                welcomeMain();
            }

            @Override
            public void onTick(long millisUntilFinished) {
                int progress = (int) ((time - millisUntilFinished) * 100 / time);
                viewBind.loadingPb.setProgress(progress);
            }
        };
        countDownTimer.start();
    }

    @Override
    protected WelActivityBinding initViewBinding() {
        return WelActivityBinding.inflate(getLayoutInflater());
    }

    private void welcomeMain() {
        viewBind.loadingPb.setProgress(100);
        Intent intent = new Intent(this, OneActivity.class);
        startActivity(intent);
        finish();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (countDownTimer != null) {
            countDownTimer.cancel();
        }
    }
}