package org.tensorflow.lite.examples.poseestimation

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class SplashActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)

        val textView = findViewById<TextView>(R.id.some_id)
        val vector1 = findViewById<View>(R.id.vector1)
        val vector2 = findViewById<View>(R.id.vector2)

        // 获取屏幕高度
        val screenHeight = resources.displayMetrics.heightPixels
        val margin = screenHeight / 8

        textView.post {
            val textViewLocation = IntArray(2)
            textView.getLocationOnScreen(textViewLocation)
            val textViewTop = textViewLocation[1]
            val textViewBottom = textViewTop + textView.height

            // 设置vector1在TextView上方，右对齐
            val params1 = vector1.layoutParams as RelativeLayout.LayoutParams
            params1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT)
            params1.topMargin = textViewTop - margin - vector1.layoutParams.height
            vector1.layoutParams = params1

            // 设置vector2在TextView下方，左对齐
            val params2 = vector2.layoutParams as RelativeLayout.LayoutParams
            params2.addRule(RelativeLayout.ALIGN_PARENT_LEFT)
            params2.topMargin = textViewBottom + margin
            vector2.layoutParams = params2
        }

        // 2秒后跳转到引导页
        Handler(Looper.getMainLooper()).postDelayed({
            startActivity(Intent(this, OnboardingActivity::class.java))
            finish()
        }, 2000)
    }
} 