| | |
| | | package com.dayu.general.activity |
| | | |
| | | import android.content.Intent |
| | | import android.os.Bundle |
| | | import android.view.LayoutInflater |
| | | import android.view.View |
| | | import android.view.ViewGroup |
| | | import androidx.fragment.app.Fragment |
| | | import com.dayu.general.BaseApplication |
| | | import com.dayu.general.databinding.FragmentMyBinding |
| | | |
| | | class MyFragment:Fragment() { |
| | | 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 { |
| | | logout() |
| | | } |
| | | 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 = "未登录" |
| | | var intent= Intent(activity,LoginActivity::class.java) |
| | | startActivity(intent) |
| | | activity?.finish() |
| | | } |
| | | |
| | | |
| | | } |