bug fix :用户单点登录点击充值后显示无数据的相关问题
This commit is contained in:
parent
29ce1726ca
commit
e1bfc380d3
|
|
@ -33,12 +33,15 @@ import com.stripe.android.model.StripeIntent
|
|||
import com.tencent.mmkv.MMKV
|
||||
import com.yingmao.clash.BuildConfig
|
||||
import com.yingmao.clash.R
|
||||
import com.yingmao.clash.act.NewMainActivity.Companion.profileBinder
|
||||
import com.yingmao.clash.app.MainApplication
|
||||
import com.yingmao.clash.base.BaseActivity
|
||||
import com.yingmao.clash.conf.BZYConstants
|
||||
import com.yingmao.clash.entity.CheckLoginRsp
|
||||
import com.yingmao.clash.entity.PayUploadParamData
|
||||
import com.yingmao.clash.entity.RechargeModelEntity
|
||||
import com.yingmao.clash.fragment.NewAccFragment
|
||||
import com.yingmao.clash.fragment.home.HomeFragment.Companion.clashRunning
|
||||
import com.yingmao.clash.fragment.recharge.RechargeViewModel
|
||||
import com.yingmao.clash.fragment.recharge.adapter.RechargeModelAdapter
|
||||
import com.yingmao.clash.fragment.recharge.adapter.VIPRechargeAdapter
|
||||
|
|
@ -57,9 +60,11 @@ import com.yingmao.clash.view.dialog.DialogDoMainChoose
|
|||
import com.yingmao.clash.view.dialog.PayConfirmDialog
|
||||
import com.yingmao.clash.view.dialog.RxDialogShapeLoading
|
||||
import com.yingmao.clash.view.dialog.SplashDialog
|
||||
import com.yingmao.clash.vm.MainAtyVM
|
||||
import com.yingmao.clash.webview.BZYWebViewKeFu
|
||||
import com.yingmao.clash.webview.CustomerServiceWebView
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -82,6 +87,7 @@ class MemberRechargeActivity : BaseActivity() {
|
|||
private var selectedGradeID :Int=0
|
||||
//stripePay 支付
|
||||
private var paymentIntentClientSecret: String = ""
|
||||
private lateinit var mainAtyVM: MainAtyVM
|
||||
private val stripe: Stripe by lazy {
|
||||
Stripe(
|
||||
this@MemberRechargeActivity,
|
||||
|
|
@ -98,6 +104,7 @@ class MemberRechargeActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
private fun initData() {
|
||||
mainAtyVM = ViewModelProvider(this)[MainAtyVM::class.java]
|
||||
viewModel = ViewModelProvider(this)[RechargeViewModel::class.java]
|
||||
observe(this, viewModel)
|
||||
//获取充值列表
|
||||
|
|
@ -178,12 +185,19 @@ class MemberRechargeActivity : BaseActivity() {
|
|||
HttpReqType.GET_RECHARGE_INFO -> {
|
||||
Logger.d("获取充值续费信息请求成功")
|
||||
swipeLayout.isRefreshing = false
|
||||
(httpStatus.rsp as RechargeInfoRsp).let { it ->
|
||||
if (it.code != "1000") {
|
||||
RxToast.error(if (it.message.isNullOrBlank())resources.getString(R.string.FailedRechargeList)+ "(${it.code})" else "${it.code}:${it.message}")
|
||||
} else {
|
||||
it.data?.let { rechargeInfo ->
|
||||
initAdapter(rechargeInfo)
|
||||
(httpStatus.rsp as RechargeInfoRsp).let {
|
||||
when (it.code) {
|
||||
"1088" -> {
|
||||
RxToast.info(resources.getString(R.string.LoginOut))
|
||||
cleanUserInfo()
|
||||
}
|
||||
"1000" -> {
|
||||
it.data?.let { rechargeInfo ->
|
||||
initAdapter(rechargeInfo)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
RxToast.error(if (it.message.isNullOrBlank())resources.getString(R.string.FailedRechargeList)+ "(${it.code})" else "${it.code}:${it.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -506,4 +520,36 @@ class MemberRechargeActivity : BaseActivity() {
|
|||
|
||||
}
|
||||
}
|
||||
private fun cleanUserInfo() {
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_PH_TOKEN)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_TOKEN)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_CURRENT_NODE)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.NODE_SELECTED_NAME_KEY)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_VPN_UserCommand)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.NODE_All_ITEM_NAME_KEY)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.PROFILE_SUB_URL)
|
||||
Log.d("cleanUserInfo clashRunning==>$clashRunning")
|
||||
if (clashRunning) {
|
||||
NewAccFragment().stopClash()
|
||||
}
|
||||
mainAtyVM.stopHeartBeat()
|
||||
cleanProfile()
|
||||
val intent=Intent(CommonUtils.getApp(), LoginActivity::class.java)
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
private fun cleanProfile() {
|
||||
Log.d("cleanProfile start")
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
profileBinder?.let { pm ->
|
||||
pm.queryAll().forEach { profile ->
|
||||
Log.d("cleanProfile go delete name==>${profile.name}, uuid==>${profile.uuid}")
|
||||
pm.delete(profile.uuid)
|
||||
}
|
||||
} ?: let {
|
||||
Log.d("profileBinder is null")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -680,7 +680,10 @@ class NewMainActivity : BaseActivity() {
|
|||
} else {
|
||||
// RxToast.info(resources.getString(R.string.PaymentResultsStr))
|
||||
}
|
||||
} else {
|
||||
} else if(checkLoginRsp.code == -2){
|
||||
RxToast.info(resources.getString(R.string.LoginOut))
|
||||
cleanUserInfoToLogout()
|
||||
}else{
|
||||
RxToast.info(resources.getString(R.string.QueryFailed))
|
||||
}
|
||||
payResultLoading?.dismiss()
|
||||
|
|
@ -979,6 +982,26 @@ class NewMainActivity : BaseActivity() {
|
|||
startActivity(Intent(CommonUtils.getApp(), LoginActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
private fun cleanUserInfoToLogout() {
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_PH_TOKEN)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_TOKEN)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_CURRENT_NODE)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.NODE_SELECTED_NAME_KEY)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.MMKV_KEY_VPN_UserCommand)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.NODE_All_ITEM_NAME_KEY)
|
||||
MMKV.defaultMMKV().removeValueForKey(BZYConstants.PROFILE_SUB_URL)
|
||||
Log.d("cleanUserInfo clashRunning==>${clashRunning}")
|
||||
if (clashRunning) {
|
||||
fragments.filterIsInstance<NewAccFragment>().forEach { it.stopClash() }
|
||||
}
|
||||
stopUploadTimer()
|
||||
mainAtyVM.stopHeartBeat()
|
||||
cleanProfile()
|
||||
val intent=Intent(CommonUtils.getApp(), LoginActivity::class.java)
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
|
||||
private fun cleanProfile() {
|
||||
|
|
|
|||
|
|
@ -398,5 +398,6 @@ Service Description\n
|
|||
<string name="Switching">Switching, please wait</string>
|
||||
<string name="switchManually">The current node is congested, please switch manually</string>
|
||||
<string name="SwitchingSource">Please turn off acceleration before switching sources</string>
|
||||
<string name="LoginOut">It is detected that the current account is logged in on other devices. If it is not your own operation, please change the password immediately and log out of the unfamiliar device.</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -388,4 +388,6 @@
|
|||
<string name="Switching">切換中,請稍後</string>
|
||||
<string name="switchManually">當前節點擁堵請手動切換</string>
|
||||
<string name="SwitchingSource">請關閉加速後在進行源切換</string>
|
||||
<string name="LoginOut">檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -386,4 +386,6 @@
|
|||
<string name="Switching">切換中,請稍後</string>
|
||||
<string name="switchManually">當前節點擁堵請手動切換</string>
|
||||
<string name="SwitchingSource">請關閉加速後在進行源切換</string>
|
||||
<string name="LoginOut">檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -412,4 +412,6 @@
|
|||
<string name="Switching">切换中,请稍后</string>
|
||||
<string name="switchManually">当前节点拥堵请手动切换</string>
|
||||
<string name="SwitchingSource">请关闭加速后在进行源切换</string>
|
||||
<string name="LoginOut">检测到当前账号在其他设备登录,如非本人操作,请立即修改密码并退出陌生设备。</string>
|
||||
|
||||
</resources>
|
||||
Loading…
Reference in New Issue