package com.example.smartlab

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.CountDownTimer
import android.view.animation.AnimationUtils;
import android.widget.TextView
import com.example.smartlab.databinding.ActivitySplashPaymentBinding

class SplashPaymentActivity : AppCompatActivity() {
    lateinit var binding: ActivitySplashPaymentBinding
    lateinit var edit_text: TextView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivitySplashPaymentBinding.inflate(layoutInflater)
        setContentView(binding.root)

        edit_text = binding.paymentText

        activityFun()
    }

    private fun activityFun(){

        object : CountDownTimer(3600000, 1500) {

            override fun onTick(millisUntilFinished: Long) {
                val animation = AnimationUtils.loadAnimation(this@SplashPaymentActivity, R.anim.elipse_rotation)
                    binding.elipse.startAnimation(animation)
            }

            override fun onFinish() {
            }
        }.start()

        var num = 0
        val items= resources.getStringArray(R.array.payment_text)

        object : CountDownTimer(3600000, 3500) {

            override fun onTick(millisUntilFinished: Long) {
                when(num){
                    0 -> {
                        num = 1
                        edit_text.text = items[0]
                    }
                    1 -> {
                        num = 2
                        edit_text.text = items[1]
                    }
                    2 ->{
                        num = 3
                        edit_text.text = items[2]
                    }
                    else -> {
                        num = 1;
                        edit_text.text = items[0]
                    }
                }
            }

            override fun onFinish() {
            }
        }.start()
    }

}