package com.example.prettywallpapers.activity;

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

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.prettywallpapers.R;
import com.example.prettywallpapers.toponad.AdManager;

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

public class IntoActivity extends AppCompatActivity {

    private CountDownTimer countDownTimer;
    private Long tim = 8000L;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_into);
        countDownTimer = AdManager.showWelcomeAd(IntoActivity.this, tim, new Function0<Unit>() {
            @Override
            public Unit invoke() {
                startMainActivity();
                return null;
            }
        });
        countDownTimer.start();
    }

    private void startMainActivity() {
        Intent intent = new  Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        countDownTimer.cancel();
    }
}