package com.baijiayun.live.ui.speakpanel

import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.baijiayun.live.ui.R
import com.baijiayun.live.ui.databinding.FragmentPadSpeakersBinding
import com.baijiayun.liveuibase.panel.BaseSpeakFragment

/**
 * Created by Shubo on 2019-10-10.
 */
open class SpeakFragment : BaseSpeakFragment() {
    private var _binding: FragmentPadSpeakersBinding? = null
    private val binding get() = _binding!!

    private val speakParams by lazy {
        val height = resources.getDimensionPixelSize(R.dimen.speak_video_height)
        val ratio = 16f / 9
        val width = (ratio * height).toInt()
        LinearLayout.LayoutParams(width, height)
    }

    override fun getSpeakLayoutParams() = speakParams

    override fun getSpeakContainer(): ViewGroup = binding.fragmentSpeakersContainer

    override fun getLayoutId(): Int = R.layout.fragment_pad_speakers

    override fun init(view: View) {
        super.init(view)
        _binding = FragmentPadSpeakersBinding.bind(view)
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
    companion object {
        fun newInstance() = SpeakFragment()
    }
}