diff --git a/app/src/main/java/com/yingmao/clash/fragment/home/HomeFragment.kt b/app/src/main/java/com/yingmao/clash/fragment/home/HomeFragment.kt index 434a796..c309850 100644 --- a/app/src/main/java/com/yingmao/clash/fragment/home/HomeFragment.kt +++ b/app/src/main/java/com/yingmao/clash/fragment/home/HomeFragment.kt @@ -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(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(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) {