|
@@ -25,6 +25,7 @@ import com.develop.food.base.ui.ViewBindingFragment
|
|
|
import com.develop.food.base.utils.MmkvUtils
|
|
|
import com.develop.food.base.utils.dimenRes
|
|
|
import com.develop.food.base.utils.setVisible
|
|
|
+import com.develop.food.base.widgets.CancelConfirmDialog
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
|
|
|
class MemberProfileFragment : ViewBindingFragment<FragmentMemberProfileBinding>() {
|
|
@@ -103,22 +104,35 @@ class MemberProfileFragment : ViewBindingFragment<FragmentMemberProfileBinding>(
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- binding.tvDestroyAccount.setOnClickListener {
|
|
|
- viewModel.cancelAccount().observe(viewLifecycleOwner) {
|
|
|
- EventBus.getDefault().post(FinishAtyEvent())
|
|
|
- FoodDataProvider.getUserDatabase().userInfoDao()
|
|
|
- .deleteUserInfoByUserId(CURRENT_USER_ID)
|
|
|
- val saveToken: String? = null
|
|
|
- MmkvUtils.save(API_TOKEN, saveToken)
|
|
|
- MmkvUtils.save(LOGIN_TAG, false)
|
|
|
- MmkvUtils.save(CURRENT_USER_ID_TAG, 0)
|
|
|
- MmkvUtils.save(RECORD_ACCOUNT, "")
|
|
|
- MmkvUtils.save(RECORD_PASSWORD, "")
|
|
|
- FoodDataProvider.getUserDatabase().userInfoDao().deleteAllUserInfo()
|
|
|
- parentFragmentManager.beginTransaction()
|
|
|
- .replace(R.id.fl_container, MemberLoginFragment()).commitAllowingStateLoss()
|
|
|
- }
|
|
|
|
|
|
+ val commonDialog = CancelConfirmDialog()
|
|
|
+ commonDialog.title = getString(R.string.delete_account_ask)
|
|
|
+ commonDialog.onDialogClickListener =
|
|
|
+ object : CancelConfirmDialog.OnDialogClickListener {
|
|
|
+ override fun onConfirm() {
|
|
|
+ viewModel.cancelAccount().observe(viewLifecycleOwner) {
|
|
|
+ EventBus.getDefault().post(FinishAtyEvent())
|
|
|
+ FoodDataProvider.getUserDatabase().userInfoDao()
|
|
|
+ .deleteUserInfoByUserId(CURRENT_USER_ID)
|
|
|
+ val saveToken: String? = null
|
|
|
+ MmkvUtils.save(API_TOKEN, saveToken)
|
|
|
+ MmkvUtils.save(LOGIN_TAG, false)
|
|
|
+ MmkvUtils.save(CURRENT_USER_ID_TAG, 0)
|
|
|
+ MmkvUtils.save(RECORD_ACCOUNT, "")
|
|
|
+ MmkvUtils.save(RECORD_PASSWORD, "")
|
|
|
+ FoodDataProvider.getUserDatabase().userInfoDao().deleteAllUserInfo()
|
|
|
+ parentFragmentManager.beginTransaction()
|
|
|
+ .replace(R.id.fl_container, MemberLoginFragment()).commitAllowingStateLoss()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onCancel() {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ binding.tvDestroyAccount.setOnClickListener {
|
|
|
+ commonDialog.showDialog(childFragmentManager,"deleteCommonDialog")
|
|
|
}
|
|
|
userInfoLiveData.observe(viewLifecycleOwner) {
|
|
|
it?.apply {
|