package com.live.mylivewallpaper.activity;

import androidx.appcompat.app.AppCompatActivity;

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

import com.live.mylivewallpaper.R;
import com.live.mylivewallpaper.base.BaseActivity;
import com.live.mylivewallpaper.databinding.ActivityWelcomeBinding;
import com.live.mylivewallpaper.topon.AdManager;
import com.live.mylivewallpaper.topon.CountAction;
import com.live.mylivewallpaper.topon.GoMainAction;

public class WelcomeActivity extends BaseActivity<ActivityWelcomeBinding> {

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

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

    @Override
    protected void onCreateInit() {

        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 true;
    }

    @Override
    public void onClick(View view) {

    }
}