package com.xm.test.myfilemaster.activity

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.activity.ComponentActivity
import com.xm.test.myfilemaster.R
import com.xm.test.myfilemaster.antivirus.AntivirusActivity
import com.xm.test.myfilemaster.databinding.ActivityAntivirusBinding
import com.xm.test.myfilemaster.databinding.ActivityMainBinding
import com.xm.test.myfilemaster.databinding.ResultLayoutBinding

class ResultPageActivity : ComponentActivity() {

    private lateinit var binding: ResultLayoutBinding

    private var mFromWhereType: String = ""

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
//        setContentView(R.layout.result_layout)

        binding = ResultLayoutBinding.inflate(layoutInflater)
        var view = binding.root
        setContentView(view)
        initView()
        setViewOnClickListener()

    }

    private fun initView() {
        binding.resultTitle.text = intent.getStringExtra("pageTitle") ?: ""
        binding.cleanSuccessSizeText.text = intent.getStringExtra("pageSuccessText") ?: ""
        mFromWhereType = intent.getStringExtra("pageName").toString() ?: ""
        when (mFromWhereType){
            "clean" ->{
                binding.cleanView.visibility = View.GONE
                binding.AntivirusView.visibility = View.VISIBLE
            }
            "antivirus" ->{
                binding.cleanView.visibility = View.VISIBLE
                binding.AntivirusView.visibility = View.GONE
            }
            "battery" ->{
                binding.batteryView.visibility = View.GONE
            }
        }
    }

    fun setViewOnClickListener(){
        binding.goToAntivirus.setOnClickListener {
            startActivity(Intent(this, AntivirusActivity::class.java))
            finish()
        }
        binding.goToBattery.setOnClickListener {
            startActivity(Intent(this, BatteryActivity::class.java))
            finish()
        }
        binding.goToScanLarge.setOnClickListener {
            startActivity(Intent(this, ScanLargeFilesActivity::class.java))
            finish()
        }
        binding.goToScanSimilarImages.setOnClickListener {
            startActivity(Intent(this, SimilarImagesActivity::class.java))
            finish()
        }
        binding.goToClean.setOnClickListener {
            startActivity(Intent(this, CleanActivity::class.java))
            finish()
        }
        binding.resultQuitBtn.setOnClickListener {
            finish()
        }
    }


}