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