package com.prankapp.fartsounds.airhorn.splash_prank;

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

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.prankapp.fartsounds.airhorn.MainActivity;
import com.prankapp.fartsounds.airhorn.R;
import com.prankapp.fartsounds.airhorn.openmediation.AdManager;

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

public class SplashActivity extends AppCompatActivity {



    private Long totalTim = 11000L;
    private CountDownTimer countDownTimer;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
          setContentView(R.layout.splash_activity);
        countDownTimer = AdManager.showWelcomeAd(SplashActivity.this,totalTim, new Function0<Unit>() {
            @Override
            public Unit invoke() {
                go();
                return null;
            }
        });
        countDownTimer.start();


    }

    private void go() {
        finish();
        startActivity(new Intent(SplashActivity.this, MainActivity.class));
    }

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

    }




}
