package com.gh.gamecenter.qa.video.publish

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.entity.CommunityEntity
import com.gh.gamecenter.common.utils.updateStatusBarColor
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.qa.BbsType

class VideoPublishActivity : ToolBarActivity() {
    override fun getLayoutId(): Int = R.layout.activity_video_publish

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mToolbar.navigationIcon = null
        findViewById<View>(R.id.backBtn).setOnClickListener { onBackPressed() }
    }

    override fun isAutoResetViewBackgroundEnabled(): Boolean = true

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        updateStatusBarColor(R.color.background_white, R.color.background_white)
    }

    companion object {

        @JvmStatic
        fun getIntent(
            context: Context,
            communityEntity: CommunityEntity? = null,
            gameEntity: GameEntity? = null,
            activityLabel: ActivityLabelEntity? = null,
            type: String,
            disableForumSelection: Boolean = false,
            entrance: String,
            path: String
        ): Intent {
            return getIntent(
                context,
                communityEntity,
                gameEntity,
                activityLabel,
                type,
                disableForumSelection,
                false,
                entrance,
                path
            )
        }

        @JvmStatic
        fun getIntent(
            context: Context,
            communityEntity: CommunityEntity? = null,
            gameEntity: GameEntity? = null,
            activityLabel: ActivityLabelEntity? = null,
            type: String,
            disableForumSelection: Boolean = false,
            isFromCommunityActivity: Boolean = false,
            entrance: String,
            path: String
        ): Intent {
            val bundle = Bundle()
            bundle.putParcelable(CommunityEntity::class.java.simpleName, communityEntity)
            bundle.putParcelable(ActivityLabelEntity::class.java.simpleName, activityLabel)
            bundle.putParcelable(GameEntity::class.java.simpleName, gameEntity)
            bundle.putString(BbsType::class.java.simpleName, type)
            bundle.putBoolean(VideoPublishFragment.IS_FORUM_SELECTION_DISABLED, disableForumSelection)
            bundle.putString(EntranceConsts.KEY_ENTRANCE, ToolBarActivity.mergeEntranceAndPath(entrance, path))
            bundle.putString(EntranceConsts.KEY_PATH, path)
            bundle.putBoolean(VideoPublishFragment.IS_FROM_COMMUNITY_ACTIVITY, isFromCommunityActivity)
            return getTargetIntent(context, VideoPublishActivity::class.java, VideoPublishFragment::class.java, bundle)
        }

        @JvmStatic
        fun getIntent(context: Context, videoEntity: ForumVideoEntity, entrance: String, path: String): Intent {
            val bundle = Bundle()
            bundle.putParcelable(ForumVideoEntity::class.java.simpleName, videoEntity)
            bundle.putString(EntranceConsts.KEY_ENTRANCE, ToolBarActivity.mergeEntranceAndPath(entrance, path))
            bundle.putString(EntranceConsts.KEY_PATH, path)
            return getTargetIntent(context, VideoPublishActivity::class.java, VideoPublishFragment::class.java, bundle)
        }

        @JvmStatic
        fun getDraftIntent(context: Context, draftEntity: VideoDraftEntity, entrance: String, path: String): Intent {
            val bundle = Bundle()
            bundle.putParcelable(VideoDraftEntity::class.java.simpleName, draftEntity)
            bundle.putString(EntranceConsts.KEY_ENTRANCE, ToolBarActivity.mergeEntranceAndPath(entrance, path))
            bundle.putString(EntranceConsts.KEY_PATH, path)
            return getTargetIntent(context, VideoPublishActivity::class.java, VideoPublishFragment::class.java, bundle)
        }
    }

}