package com.gh.gamecenter.qa.editor

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.R
import com.zhihu.matisse.internal.entity.Item

class PreviewVideoActivity : BaseActivity() {
    override fun getLayoutId(): Int {
        return R.layout.activity_amway
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        DisplayUtils.transparentStatusBar(this)

        val containerFragment = supportFragmentManager.findFragmentByTag(PreviewVideoFragment::class.java.name)
            ?: PreviewVideoFragment().with(intent.extras)
        // 若 placeholder 外层为 RelativeLayout 的话，会出现莫名的偏移
        supportFragmentManager.beginTransaction()
            .replace(R.id.placeholder, containerFragment, PreviewVideoFragment::class.java.name)
            .commitAllowingStateLoss()
    }

    companion object {
        fun getIntent(context: Context, videos: ArrayList<Item>): Intent {
            val intent = Intent(context, PreviewVideoActivity::class.java)
            intent.putExtra(EntranceConsts.KEY_VIDEO_LIST, videos)
            return intent
        }
    }
}