package com.gh.gamecenter.help

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.databinding.ActivityHelpDetailBinding
import com.gh.gamecenter.entity.HelpEntity

class HelpDetailActivity : ToolBarActivity() {
    private lateinit var mBinding: ActivityHelpDetailBinding

    override fun getLayoutId(): Int {
        return R.layout.activity_help_detail
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mBinding = ActivityHelpDetailBinding.bind(mContentView)

        val helpEntity = intent.getParcelableExtra<HelpEntity>(HelpEntity::class.java.simpleName)
        if (helpEntity != null) {
            mBinding.title.text = helpEntity.title
            mBinding.content.text = helpEntity.content
        }
    }

    override fun getBusinessId(): Pair<String, String> {
        val helpEntity = intent.getParcelableExtra<HelpEntity>(HelpEntity::class.java.simpleName)
        return if (helpEntity != null) {
            Pair(helpEntity.id, "")
        } else {
            super.getBusinessId()
        }
    }

    companion object {
        fun getIntent(context: Context, entity: HelpEntity): Intent {
            val intent = Intent(context, HelpDetailActivity::class.java)
            intent.putExtra(HelpEntity::class.java.simpleName, entity)
            return intent
        }
    }
}