充值界面备用源切换
This commit is contained in:
parent
a417929817
commit
c171177786
|
|
@ -254,7 +254,7 @@ class ChangeNodeActivity : BaseActivity(), View.OnClickListener {
|
|||
profileManager.setActive(profile)
|
||||
delay(500)
|
||||
if (!TextUtils.isEmpty(profile.source)) {
|
||||
Log.d("updateProfile pro.source==>${profile.source}, url==>${nowSubUrl}")
|
||||
// Log.d("updateProfile pro.source==>${profile.source}, url==>${nowSubUrl}")
|
||||
if (profile.source != nowSubUrl) {
|
||||
Log.d("updateProfile patch")
|
||||
profileManager.patch(
|
||||
|
|
@ -523,7 +523,7 @@ class ChangeNodeActivity : BaseActivity(), View.OnClickListener {
|
|||
override fun tryButton() {
|
||||
var currentHost = MMKV.defaultMMKV()
|
||||
.decodeString(BZYConstants.MMKV_KEY_CURRENT_HOST, "")
|
||||
com.cncat.vpn.common.log.Log.d("tryButton currentHost==>${currentHost}")
|
||||
// com.cncat.vpn.common.log.Log.d("tryButton currentHost==>${currentHost}")
|
||||
var oldUrl = nowSubUrl
|
||||
currentHost?.let { changeSubUrl(oldUrl, it) }
|
||||
doProfile()
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class LoginActivity : BaseActivity(), View.OnClickListener {
|
|||
override fun tryButton() {
|
||||
var currentHost = MMKV.defaultMMKV()
|
||||
.decodeString(BZYConstants.MMKV_KEY_CURRENT_HOST, "")
|
||||
com.cncat.vpn.common.log.Log.d("tryButton CHECK_LOGIN currentHost==>${currentHost}")
|
||||
// com.cncat.vpn.common.log.Log.d("tryButton CHECK_LOGIN currentHost==>${currentHost}")
|
||||
loginViewMode.login(username_encrypt, password_encrypt)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ class SplashHelper(private val splashAtyVM: PublicViewMode) {
|
|||
|
||||
fun getHostWithFallback(callback: (Boolean) -> Unit) {
|
||||
tryGetHost(
|
||||
{ splashAtyVM.getHostByGithub(it) },
|
||||
{ splashAtyVM.getHostByAWS(it) },
|
||||
{ splashAtyVM.getHost(it) },
|
||||
{ splashAtyVM.getHostByAWS(it) },
|
||||
{ splashAtyVM.getHostByGithub(it) },
|
||||
callback
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,15 +156,15 @@ class SplashActivity : BaseActivity() {
|
|||
// 八爪鱼 2
|
||||
// com.cncat.vpn.common.log.Log.d("bzy2 encrypt:"+ AESUtil.byteArrayToHexStr(AESUtil.encrypt("")))
|
||||
// 影猫
|
||||
com.cncat.vpn.common.log.Log.d(
|
||||
"ym encrypt:" +
|
||||
AESUtil.byteArrayToHexStr(
|
||||
AESUtil.encrypt(
|
||||
"https://yingmaohot.org+https://yingmao888.net+" +
|
||||
"https://ymsohot.com+https://ma.wztgyh.com+https://ymapi.yingmaox.cc"
|
||||
)
|
||||
)
|
||||
)
|
||||
// com.cncat.vpn.common.log.Log.d(
|
||||
// "ym encrypt:" +
|
||||
// AESUtil.byteArrayToHexStr(
|
||||
// AESUtil.encrypt(
|
||||
// "https://api.yingmaohot.org+https://api.yingmao888.net+" +
|
||||
// "https://api.ymsohot.com+https://ma.wztgyh.com+https://ymapi.yingmaox.cc"
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
val routerSet =
|
||||
MMKV.defaultMMKV().decodeStringSet(BZYConstants.MMKV_KEY_ROUTER_HOST)
|
||||
if (routerSet != null && routerSet.size > 0) {
|
||||
|
|
@ -650,7 +650,7 @@ class SplashActivity : BaseActivity() {
|
|||
override fun tryButton() {
|
||||
var currentHost = MMKV.defaultMMKV()
|
||||
.decodeString(BZYConstants.MMKV_KEY_CURRENT_HOST, "")
|
||||
com.cncat.vpn.common.log.Log.d("tryButton currentHost==>${currentHost}")
|
||||
// com.cncat.vpn.common.log.Log.d("tryButton currentHost==>${currentHost}")
|
||||
doRegisterByEncryption()
|
||||
}
|
||||
|
||||
|
|
@ -718,7 +718,7 @@ class SplashActivity : BaseActivity() {
|
|||
override fun tryButton() {
|
||||
var currentHost = MMKV.defaultMMKV()
|
||||
.decodeString(BZYConstants.MMKV_KEY_CURRENT_HOST, "")
|
||||
com.cncat.vpn.common.log.Log.d("tryButton CHECK_LOGIN currentHost==>${currentHost}")
|
||||
// com.cncat.vpn.common.log.Log.d("tryButton CHECK_LOGIN currentHost==>${currentHost}")
|
||||
splashAtyVM.checkLogin()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ fun getHost(callback: AsyncCallback) {
|
|||
}
|
||||
|
||||
fun getHostByGithub(callback: AsyncCallback) {
|
||||
val rt = NetService.instances.createFreeBaseUrl("https://raw.githubusercontent1.com/")
|
||||
val rt = NetService.instances.createFreeBaseUrl("https://raw.githubusercontent.com/")
|
||||
doAsyncNoNeedReturn(HttpReqType.GET_HOST) {
|
||||
try {
|
||||
val host = when {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import com.tencent.mmkv.MMKV
|
|||
import com.yingmao.clash.R
|
||||
import com.yingmao.clash.act.ExpensesRecordActivity
|
||||
import com.yingmao.clash.act.NewMainActivity
|
||||
import com.yingmao.clash.act.SplashHelper
|
||||
import com.yingmao.clash.conf.BZYConstants
|
||||
import com.yingmao.clash.conf.PayType
|
||||
import com.yingmao.clash.entity.CheckLoginRsp
|
||||
|
|
@ -63,12 +64,14 @@ import com.yingmao.clash.util.CommonUtils
|
|||
import com.yingmao.clash.util.PayUtils
|
||||
import com.yingmao.clash.util.ThreadUtils.runOnUiThread
|
||||
import com.yingmao.clash.view.RxToast
|
||||
import com.yingmao.clash.view.dialog.DialogDoMainChoose
|
||||
import com.yingmao.clash.view.dialog.DialogPayTypeChoose
|
||||
import com.yingmao.clash.view.dialog.RxDialogShapeLoading
|
||||
import com.yingmao.clash.webview.BZYWebViewActivity
|
||||
import com.yingmao.clash.webview.BZYWebViewNormal
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.DecimalFormat
|
||||
|
||||
|
|
@ -279,7 +282,7 @@ class RechargeFragment : BaseFragment() {
|
|||
val username = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_REMEMBER_USERNAME,"")!!
|
||||
|
||||
val phToken = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_PH_TOKEN,"")!!
|
||||
viewModel.getPointCardSurplus(username, phToken)
|
||||
// viewModel.getPointCardSurplus(username, phToken)
|
||||
val userId = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_USER_ID)!!
|
||||
viewModel.getPhRechargeInfo(username, phToken, userId)
|
||||
observe(this, viewModel)
|
||||
|
|
@ -287,9 +290,9 @@ class RechargeFragment : BaseFragment() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val username = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_REMEMBER_USERNAME,"")!!
|
||||
val phToken = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_PH_TOKEN,"")!!
|
||||
viewModel.getPointCardSurplus(username, phToken)
|
||||
// val username = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_REMEMBER_USERNAME,"")!!
|
||||
// val phToken = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_PH_TOKEN,"")!!
|
||||
// viewModel.getPointCardSurplus(username, phToken)
|
||||
}
|
||||
|
||||
override fun httpLoading(httpStatus: HttpStatus.Loading) {
|
||||
|
|
@ -385,6 +388,7 @@ class RechargeFragment : BaseFragment() {
|
|||
|
||||
HttpReqType.GET_RECHARGE_INFO -> {
|
||||
Logger.d("获取充值续费信息请求成功")
|
||||
dialogDoMainChoose?.dismiss()
|
||||
swipeLayout.isRefreshing = false
|
||||
(httpStatus.rsp as RechargeInfoRsp).let { it ->
|
||||
if (it.code != "1000") {
|
||||
|
|
@ -787,7 +791,42 @@ class RechargeFragment : BaseFragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
var dialogDoMainChoose:DialogDoMainChoose? =null
|
||||
private fun showDomainList() {
|
||||
try {
|
||||
SplashHelper(viewModel).getHostWithFallback { success ->
|
||||
MainScope().launch {
|
||||
if (success) {
|
||||
if (dialogDoMainChoose==null) {
|
||||
dialogDoMainChoose = DialogDoMainChoose(this@RechargeFragment.activity)
|
||||
}
|
||||
if (dialogDoMainChoose?.isShowing==false) {
|
||||
dialogDoMainChoose?.setOnTryButtonListener(object :
|
||||
DialogDoMainChoose.OnTryButtonListener {
|
||||
override fun tryButton() {
|
||||
val username = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_REMEMBER_USERNAME,"")!!
|
||||
|
||||
val phToken = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_PH_TOKEN,"")!!
|
||||
// viewModel.getPointCardSurplus(username, phToken)
|
||||
val userId = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_USER_ID)!!
|
||||
viewModel.getPhRechargeInfo(username, phToken, userId)
|
||||
}
|
||||
|
||||
override fun cancel() {
|
||||
com.cncat.vpn.common.log.Log.d("tryButton CHECK_LOGIN cancel")
|
||||
dialogDoMainChoose?.dismiss()
|
||||
}
|
||||
})
|
||||
dialogDoMainChoose?.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
override fun httpFailure(httpStatus: HttpStatus.Failure) {
|
||||
if (::rxDialogShapeLoading.isInitialized && rxDialogShapeLoading.isShowing) {
|
||||
rxDialogShapeLoading.cancel()
|
||||
|
|
@ -813,6 +852,7 @@ class RechargeFragment : BaseFragment() {
|
|||
}
|
||||
|
||||
HttpReqType.GET_RECHARGE_INFO -> {
|
||||
showDomainList()
|
||||
Logger.d("获取充值续费信息异常${httpStatus.msg}")
|
||||
swipeLayout.isRefreshing = false
|
||||
resources.getString(R.string.DataError)
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ interface HttpApi {
|
|||
// suspend fun getHost() : String
|
||||
|
||||
//影猫
|
||||
@GET("/host.txt")
|
||||
@GET("/host_ym.txt")
|
||||
suspend fun getHost(): String
|
||||
@GET("/host_ym.txt")
|
||||
suspend fun getHostAWS(): String
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ open class DialogDoMainChoose : RxDialog {
|
|||
var mmkv = MMKV.defaultMMKV()
|
||||
|
||||
var currentHost = mmkv.decodeString(BZYConstants.MMKV_KEY_CURRENT_HOST, "")
|
||||
Log.d("currentHost==>${currentHost}")
|
||||
// Log.d("currentHost==>${currentHost}")
|
||||
for ((index, node) in nodes.withIndex()) {
|
||||
if (node.address == currentHost) {
|
||||
domainListAdapter.selectedPosition = index
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ class BZYWebViewNormal : AppCompatActivity() {
|
|||
if (routerHost.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
Log.d("routerHost==>${routerHost}, currentHost==>${currentHost}}")
|
||||
// Log.d("routerHost==>${routerHost}, currentHost==>${currentHost}}")
|
||||
routerHost.forEach { r ->
|
||||
if (!r.equals(currentHost)) {
|
||||
Log.d("go new url r==>${r}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue