Commit 2ac9369d authored by liusheng's avatar liusheng

处理vip过期

parent f1e1acbe
......@@ -241,7 +241,10 @@ class AccelertorFragment : XPageFragment() {
binding.btnQuick.isEnabled = false
startAnim()
} else {
MemberDialog(this@AccelertorFragment).show<MemberDialog>()
//MemberDialog(this@AccelertorFragment).show<MemberDialog>()
//TODO 测试
binding.btnQuick.isEnabled = false
startAnim()
}
}
} else {
......
......@@ -57,6 +57,10 @@ object AcceleratorUtils {
}
var vipExpireListener: () -> Unit = { ->
}
fun getGameList(xPageFragment: XPageFragment, callback: (Boolean) -> Unit) {
game?.let {
callback(true)
......@@ -191,6 +195,8 @@ object AcceleratorUtils {
}
}
fun stopAccelerator() {
Core.stopService()
}
......@@ -200,7 +206,11 @@ object AcceleratorUtils {
AcceleratorUtils.state = state
stateListener(state, getAccTime(), null)
if (state == BaseService.State.Stopped && !msg.isNullOrBlank()) {
ToastUtils.show(msg)
if("vip到期".equals(msg)){
}else{
ToastUtils.show(msg)
}
}
}
......
package com.github.shadowsocks.bg
import android.os.Build
import android.util.Log
import com.github.shadowsocks.Core
import com.github.shadowsocks.database.Profile
import com.github.shadowsocks.database.ProfileManager
......@@ -89,16 +90,18 @@ object AuthManager {
suspend fun initAuthProfile(profile: Profile) {
withContext(Dispatchers.IO) {
getLineConfig()?.let {
if (it.code != 200) {
return@withContext
}else if(it.code==1001){//vip过期
if(it.code==1001){//vip过期
throw AuthException(it.error)
}else if (it.code != 200) {
throw AuthException(it.error)
}
profile.host = it.data.host
profile.token = it.data.token
profile.remotePort = it.data.port
Timber.d("start vpn with games: ${profile.individual}, profileId: ${profile.id}, route: ${profile.route}")
ProfileManager.updateProfile(profile)
}?: let {
throw AuthException("未知错误")
}
}
}
......@@ -166,6 +169,8 @@ object AuthManager {
val response: Response = call.execute()
if (response.isSuccessful) {
val string = response.body?.string()
Log.e("postSync","=====url:"+HttpConfig.baseUrl + url)
Log.e("postSync","=====result:"+string)
println(string)
val type = object : TypeToken<T>() {}.type
return gson.fromJson(string, type)
......
......@@ -2,7 +2,8 @@ package com.github.shadowsocks.http
data class LineConfig(
val code: Int,
val `data`: Data
val `data`: Data,
val error:String
)
data class Data(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment