package com.example.prettywallpapers.activity;

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

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.other.CustomProgressBar;
import com.example.prettywallpapers.toponad.AdManager;

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

public class IntoActivity extends AppCompatActivity {

    private CountDownTimer countDownTimer;
    private Long tim = 10000L;
    private CustomProgressBar customProgressBar;
    private float count = 0F;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_into);
        customProgressBar = findViewById(R.id.progressBar);
        /*countDownTimer = AdManager.showWelcomeAd(IntoActivity.this, tim, new Function1<Long, Unit>() {
            @Override
            public Unit invoke(Long aLong) {
                count = count+1;

                Log.d("------------","------------count="+count);
                customProgressBar.setProgress(count);


                return null;
            }
        },new Function0<Unit>() {
            @Override
            public Unit invoke() {
                customProgressBar.setProgress(100);
                startMainActivity();
                return null;
            }
        });
        countDownTimer.start();*/
        countDownTimer = new CountDownTimer(1000,500) {
            @Override
            public void onTick(long millisUntilFinished) {

            }

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

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

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