左晓为主开发手持机充值管理机
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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() {
    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()
    }
 
 
}