|
@@ -1,5 +1,6 @@
|
|
package com.sambath.kunkhmer.screen.account
|
|
package com.sambath.kunkhmer.screen.account
|
|
|
|
|
|
|
|
+import android.content.Intent
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import androidx.fragment.app.Fragment
|
|
import androidx.fragment.app.Fragment
|
|
import android.view.LayoutInflater
|
|
import android.view.LayoutInflater
|
|
@@ -8,10 +9,13 @@ import android.view.ViewGroup
|
|
import com.sambath.kunkhmer.R
|
|
import com.sambath.kunkhmer.R
|
|
import com.sambath.kunkhmer.app.App
|
|
import com.sambath.kunkhmer.app.App
|
|
import com.sambath.kunkhmer.remote.User
|
|
import com.sambath.kunkhmer.remote.User
|
|
|
|
+import com.sambath.kunkhmer.screen.login.LoginActivity
|
|
import com.sambath.kunkhmer.util.Const
|
|
import com.sambath.kunkhmer.util.Const
|
|
import com.sambath.kunkhmer.util.ModelPreferencesManager
|
|
import com.sambath.kunkhmer.util.ModelPreferencesManager
|
|
|
|
+import com.sambath.kunkhmer.util.PrefHelper
|
|
import kotlinx.android.synthetic.main.fragment_account.view.country_tv
|
|
import kotlinx.android.synthetic.main.fragment_account.view.country_tv
|
|
import kotlinx.android.synthetic.main.fragment_account.view.email_tv
|
|
import kotlinx.android.synthetic.main.fragment_account.view.email_tv
|
|
|
|
+import kotlinx.android.synthetic.main.fragment_account.view.logout_btn
|
|
import kotlinx.android.synthetic.main.fragment_account.view.member_tv
|
|
import kotlinx.android.synthetic.main.fragment_account.view.member_tv
|
|
import kotlinx.android.synthetic.main.fragment_account.view.username_tv
|
|
import kotlinx.android.synthetic.main.fragment_account.view.username_tv
|
|
import java.text.SimpleDateFormat
|
|
import java.text.SimpleDateFormat
|
|
@@ -23,6 +27,7 @@ class AccountFragment : Fragment() {
|
|
private val binding get() = _root!!
|
|
private val binding get() = _root!!
|
|
private lateinit var user: User
|
|
private lateinit var user: User
|
|
private lateinit var accountViewModel: AccountViewModel
|
|
private lateinit var accountViewModel: AccountViewModel
|
|
|
|
+ lateinit var sharePref: PrefHelper
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
@@ -32,6 +37,7 @@ class AccountFragment : Fragment() {
|
|
// Inflate the layout for this fragment
|
|
// Inflate the layout for this fragment
|
|
_root = inflater.inflate(R.layout.fragment_account, container, false)
|
|
_root = inflater.inflate(R.layout.fragment_account, container, false)
|
|
user = ModelPreferencesManager.get<User>(Const.USER_KEY)!!
|
|
user = ModelPreferencesManager.get<User>(Const.USER_KEY)!!
|
|
|
|
+ sharePref = App.injectPrefHelper()
|
|
|
|
|
|
binding.username_tv.text = user.userName
|
|
binding.username_tv.text = user.userName
|
|
accountViewModel = AccountViewModel(App.injectApiService(), App.injectPrefHelper())
|
|
accountViewModel = AccountViewModel(App.injectApiService(), App.injectPrefHelper())
|
|
@@ -40,6 +46,17 @@ class AccountFragment : Fragment() {
|
|
render(it)
|
|
render(it)
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ binding.logout_btn.setOnClickListener{
|
|
|
|
+ // Clear user-related data or preferences, such as the user token.
|
|
|
|
+ sharePref.logout()
|
|
|
|
+ // Redirect the user to the login screen or perform any other necessary actions.
|
|
|
|
+ // For example, you can start a new activity or fragment for the login screen:
|
|
|
|
+ val intent = Intent(context, LoginActivity::class.java)
|
|
|
|
+ intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
|
|
|
+ startActivity(intent)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
return _root
|
|
return _root
|
|
}
|
|
}
|
|
|
|
|