package com.zj365.health.act

import android.annotation.SuppressLint
import android.content.Intent
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.xty.base.act.IBaseAct
import com.xty.common.arouter.ARouterUrl
import com.zj365.health.R
import com.zj365.health.databinding.ActHouseKeeperBinding
import com.zj365.health.fragment.DataUploadFrag
import com.zj365.health.fragment.MyKeeperFrag


/**
 * 健康管家
 */
@Route(path = ARouterUrl.HOUSE_KEEPER)
class HousekeeperAct : IBaseAct() {
    private val fragmentManager: FragmentManager = supportFragmentManager

    val binding by lazy { ActHouseKeeperBinding.inflate(layoutInflater) }

    var fromUserId: String = ""
    override fun setLayout() = binding.root
    override fun initData() {
        super.initData()
        intent.extras?.let {
            fromUserId =it.getString("fromUserId").toString()
        }


    }

    @SuppressLint("CommitTransaction")
    override fun initView() {
        super.initView()
        statusBar(binding.title.mView)
        binding.title.mIvBack.setOnClickListener { finish() }
        binding.title.mTvTitle.text = getString(R.string.health_gj)
       val fragment: Fragment = MyKeeperFrag().apply {
           bundle.clear()
           bundle.putString("fromUserId", fromUserId)
           this.arguments = bundle }
        fragmentManager.beginTransaction().apply {
            replace(R.id.fragment, fragment)
            commit()
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        val fragment = DataUploadFrag()
        fragment.onActivityResult(requestCode, resultCode, data)

    }

}