package com.hd.live.wallpapers.actfrag;

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

import com.hd.live.wallpapers.base.BaseActivity;
import com.hd.live.wallpapers.databinding.ActWelcomeBinding;

public class ActWelcome extends BaseActivity<ActWelcomeBinding> {

    private static final long SPLASH_TIME_OUT = 1000L;
    private CountDownTimer countDownTimer;

    @Override
    protected ActWelcomeBinding getViewBinding() {
        return ActWelcomeBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void onCreateInit() {
        countDownTimer = new CountDownTimer(SPLASH_TIME_OUT,100) {
            @Override
            public void onTick(long millisUntilFinished) {
                float v = 100 - (float) millisUntilFinished / SPLASH_TIME_OUT * 100;
                int v1 = (int) v;
                vb.progressBar.setProgress(v1);
            }

            @Override
            public void onFinish() {
                vb.progressBar.setProgress(100);
                Intent intent = new Intent(ActWelcome.this, ActMain.class);
                startActivity(intent);
                finish();
            }
        };
//        countDownTimer = AdManager.showWelcomeAd(WelcomeActivity.this, SPLASH_TIME_OUT, new CountAction() {
//            @Override
//            public void onCount(long millisUntilFinished) {
//                float v = 100 - (float) millisUntilFinished / SPLASH_TIME_OUT * 100;
//                int v1 = (int) v;
//                vb.progressBar.setProgress(v1);
//            }
//        }, new GoMainAction() {
//            @Override
//            public void onGo() {
//                vb.progressBar.setProgress(100);
//                Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
//                startActivity(intent);
//                finish();
//            }
//        });
        countDownTimer.start();
    }

    @Override
    protected void onInitClick() {

    }

    @Override
    public boolean isFullScreen() {
        return true;
    }

    @Override
    public boolean statusBarLight() {
        return false;
    }

    @Override
    public void onClick(View view) {

    }

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