package com.dayu.general.activity
|
|
import android.os.Bundle
|
import android.view.LayoutInflater
|
import android.view.View
|
import android.view.ViewGroup
|
import androidx.fragment.app.Fragment
|
import com.dayu.baselibrary.business.BusinessProvider
|
import com.dayu.baselibrary.view.ConfirmDialog
|
import com.dayu.general.BaseApplication
|
import com.dayu.general.databinding.FragmentMyBinding
|
|
class MyFragment : Fragment() {
|
var binding: FragmentMyBinding? = null;
|
override fun onCreateView(
|
inflater: LayoutInflater,
|
container: ViewGroup?,
|
savedInstanceState: Bundle?
|
): View? {
|
binding = FragmentMyBinding.inflate(inflater, container, false)
|
binding?.logoutRL?.setOnClickListener {
|
ConfirmDialog(requireContext(), "提示", "确定要退出登录吗?") {
|
logout()
|
}.show()
|
|
}
|
return binding?.root
|
}
|
|
override fun onResume() {
|
super.onResume()
|
if (BaseApplication.userName.isNotEmpty()) {
|
binding?.myName?.text = BaseApplication.userName
|
} else {
|
binding?.myName?.text = "未登录"
|
}
|
if (BaseApplication.userPhone.isNotEmpty()) {
|
binding?.myPhone?.text = BaseApplication.userPhone
|
} else {
|
binding?.myPhone?.text = "未登录"
|
}
|
if (BaseApplication.blockName.isNotEmpty()) {
|
binding?.myAdName?.text = BaseApplication.blockName
|
} else {
|
binding?.myAdName?.text = "未登录"
|
}
|
}
|
|
fun logout() {
|
BaseApplication.userId = ""
|
BaseApplication.userName = ""
|
BaseApplication.userPhone = ""
|
BaseApplication.blockId = ""
|
BaseApplication.blockName = ""
|
binding?.myName?.text = "未登录"
|
binding?.myPhone?.text = "未登录"
|
binding?.myAdName?.text = "未登录"
|
|
// 使用路由管理器跳转到登录页面
|
context?.let {
|
BusinessProvider.getBusinessProvider().startLoginNavigotor.navigateToLogin(context)
|
}
|
}
|
}
|