package com.hongyegroup.cpt_newsfeed.ui

import android.content.Intent
import android.os.Bundle
import com.guadou.cs_cptservices.base.activity.YYBaseVDBActivity
import com.guadou.lib_baselib.bean.DataBindingConfig
import com.guadou.lib_baselib.utils.CommUtils
import com.guadou.lib_baselib.utils.KeyboardUtils
import com.hongyegroup.cpt_newsfeed.BR
import com.hongyegroup.cpt_newsfeed.R
import com.hongyegroup.cpt_newsfeed.databinding.ActivityNewsfeedPostBinding
import com.hongyegroup.cpt_newsfeed.mvvm.NewsFeedPostViewModel
import dagger.hilt.android.AndroidEntryPoint

/**
 * 动态发布页面
 */
@AndroidEntryPoint
class NewsFeedPostActivity : YYBaseVDBActivity<NewsFeedPostViewModel, ActivityNewsfeedPostBinding>() {

    companion object {
        fun startInstance() {
            val context = CommUtils.getContext()
            val intent = Intent(context, NewsFeedPostActivity::class.java)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            context.startActivity(intent)
        }
    }

    override fun getDataBindingConfig(): DataBindingConfig {
        return DataBindingConfig(R.layout.activity_newsfeed_post, BR.viewModel, mViewModel)
            .addBindingParams(BR.click, ClickProxy())
    }

    override fun init(savedInstanceState: Bundle?) {
        setStatusBarBlackText()
    }

    override fun startObserve() {

    }

    /**
     * DataBinding事件处理
     */
    inner class ClickProxy {

        fun selectCountryCode() {
            KeyboardUtils.hideSoftInput(mActivity)

            setResult(-1, Intent().apply {
                putExtra("name", "zhangsan")
            })

            finish()
        }

    }
}