package com.draw.painting.test.ui;

import androidx.appcompat.app.AppCompatActivity;

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

import com.draw.painting.test.R;
import com.draw.painting.test.databinding.ActivityAlaucherBinding;
import com.draw.painting.test.manager.Utils;

import kotlin.Unit;
import kotlin.jvm.functions.Function0;

public class ALaucherActivity extends AppCompatActivity {

    private ActivityAlaucherBinding binding;
    private long time = 2000;
    private CountDownTimer countDownTimer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityAlaucherBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        Utils.setStatusBarTextColor(this, true);

//        countDownTimer = IronSourceAd.showWelComeAd(time, ALaucherActivity.this, IronSourceAd.adPlace1, new Function0<Unit>() {
//            @Override
//            public Unit invoke() {
//                enterMain();
//                return null;
//            }
//        });

        countDownTimer = new CountDownTimer(time, 200) {
            @Override
            public void onTick(long millisUntilFinished) {

            }

            @Override
            public void onFinish() {
                enterMain();
            }
        };
        countDownTimer.start();
    }

    private void enterMain() {
        Intent intent = new Intent(ALaucherActivity.this, HomeActivity.class);
        startActivity(intent);
        finish();
    }

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