package com.hongyegroup.cpt_newsfeed.ui

import android.content.Intent
import android.os.Bundle
import com.guadou.lib_baselib.base.activity.BaseVMActivity
import com.guadou.lib_baselib.base.vm.EmptyViewModel
import com.guadou.lib_baselib.utils.CommUtils
import com.hongyegroup.cpt_newsfeed.R

/**
 * 个人的主页 实际上为空容器
 * 内部加载Fragment实现
 */
class NewsFeedProfileActivity : BaseVMActivity<EmptyViewModel>() {

    private var mMemberId: String? = null
    private var isSelf: Boolean = false
    private lateinit var mNewsFeedProfileFragment: NewsFeedProfileFragment

    companion object {
        fun startInstance(memberId: String, isSelf: Boolean = false) {
            val context = CommUtils.getContext()
            val intent = Intent(context, NewsFeedProfileActivity::class.java)
            intent.putExtra("memberId", memberId)
            intent.putExtra("isSelf", isSelf)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            context.startActivity(intent)
        }
    }

    override fun getDataFromIntent(intent: Intent) {
        mMemberId = intent.getStringExtra("memberId")
        isSelf = intent.getBooleanExtra("isSelf", false)
    }

    override fun getLayoutIdRes(): Int = R.layout.activity_newsfeed_profile

    override fun init(savedInstanceState: Bundle?) {
        mNewsFeedProfileFragment = NewsFeedProfileFragment(mMemberId,isSelf)

        supportFragmentManager.beginTransaction()
            .add(R.id.fragment_container, mNewsFeedProfileFragment)
            .commitAllowingStateLoss()
    }

    override fun startObserve() {

    }

}