big fix: 线程切换问题

This commit is contained in:
level 2025-07-15 15:44:27 +08:00
parent 82b2cb5662
commit dce52cd52c
1 changed files with 28 additions and 29 deletions

View File

@ -257,12 +257,28 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
}
rxDialogSureCancel.show()
} else {
showLoading(resources.getString(R.string.Starting), requireContext())
launch {
delay(2000)
startClash()
if (checkExpire()) {
if (isAdded) {
hideLoading()
MaterialDialog(requireContext()).show {
this.cancelable(false)
cornerRadius(res = R.dimen.dp_10)
customView(
R.layout.expired_recharge__layout,
scrollable = false,
noVerticalPadding = true,
horizontalPadding = false
)
getCustomView().findViewById<TextView>(R.id.tv_pay_finish).setOnClickListener {
goNewRecharge()
dismiss()
}
}
}
return@setOnClickListener
}
showLoading(resources.getString(R.string.Starting), requireContext())
startClash(true)
}
}
clActivity.setOnClickListener {
@ -481,7 +497,7 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
if (clashRunning) {
Log.d("clashRunning $clashRunning")
} else {
startClash()
startClash(false)
}
} else {
if (::rxDialogShapeLoading.isInitialized || rxDialogShapeLoading.isShowing) {
@ -497,12 +513,12 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
if (clashRunning) {
Log.d("clashRunning $clashRunning")
} else {
startClash()
startClash(false)
}
checkGlo()
}?.run {
if (isRunNing == true && !clashRunning) {
startClash()
startClash(false)
}
}
} else if (requestCode == Proxy_Mode_REQUEST_CODE) {
@ -510,28 +526,11 @@ class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatcher
}
}
private fun startClash() {
if (checkExpire()) {
if (isAdded) {
hideLoading()
MaterialDialog(requireContext()).show {
this.cancelable(false)
cornerRadius(res = R.dimen.dp_10)
customView(
R.layout.expired_recharge__layout,
scrollable = false,
noVerticalPadding = true,
horizontalPadding = false
)
getCustomView().findViewById<TextView>(R.id.tv_pay_finish).setOnClickListener {
goNewRecharge()
dismiss()
}
}
}
return
}
private fun startClash(isStart:Boolean) {
launch {
if(isStart){
delay(2000)
}
profileBinder?.let { pm ->
val active = pm.queryActive()
if (active == null) {