package com.design.mischiefgo.ui

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import com.design.mischiefgo.ut.RandomAdapter
import com.design.mischiefgo.entity.Usual
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.design.mischiefgo.databinding.ActivityTypeInBinding
import com.design.mischiefgo.ut.EvenTopUtils

class TypeInActivity : AppCompatActivity() {
    private lateinit var binding: ActivityTypeInBinding
    private lateinit var data: Usual

    companion object {
        const val KEY_LIST_DATA = "list_data"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityTypeInBinding.inflate(layoutInflater)
        setContentView(binding.root)
        EvenTopUtils.setStatusBar(this.window)
        EvenTopUtils.setLightStatusBar(this.window, true)
        data = intent.getParcelableExtra(KEY_LIST_DATA)!!
        initView()
    }

    private fun initView() {
        Glide.with(this)
            .load(data.convert)
            .apply(RequestOptions.circleCropTransform())
            .into(binding.image)
        binding.title.text = data.name
        val adapter = RandomAdapter()
        binding.recyclerView.adapter = adapter
        binding.recyclerView.layoutManager = GridLayoutManager(this, 3)
        adapter.setList(data.infolist)
        binding.back.setOnClickListener { finish() }
    }
}