Commit 5b740373 authored by sheteng's avatar sheteng

2.0 开发 6

parent ae8e4fcb
...@@ -149,7 +149,6 @@ class GameListFragment : XPageFragment() { ...@@ -149,7 +149,6 @@ class GameListFragment : XPageFragment() {
.load(itemData.icon) .load(itemData.icon)
.into(game_img) .into(game_img)
game_name.setText(itemData.gameName) game_name.setText(itemData.gameName)
println(itemData)
if (itemData.type == 1) { if (itemData.type == 1) {
is_free.visibility = View.VISIBLE is_free.visibility = View.VISIBLE
} else { } else {
...@@ -190,6 +189,17 @@ class GameListFragment : XPageFragment() { ...@@ -190,6 +189,17 @@ class GameListFragment : XPageFragment() {
btn_download_status.visibility = View.GONE btn_download_status.visibility = View.GONE
} }
//应用加速中
else if (AcceleratorUtils.state == BaseService.State.Connected && AcceleratorUtils.game!!.id == itemData.id) {
btn_uninstall.visibility = View.GONE
btn_acc.visibility = View.GONE
btn_acc_stop.visibility = View.VISIBLE
tx_game_update_notice.visibility = View.GONE
tx_download_status.visibility = View.VISIBLE
btn_download_status.visibility = View.GONE
tx_download_size.visibility = View.GONE
tx_status.setText(SysUtils.getAccTimeString(acctime))
}
//应用升级 //应用升级
else if (!SysUtils.compareVersionTo( else if (!SysUtils.compareVersionTo(
AppUtils.getAppVersionName(itemData.packageName), AppUtils.getAppVersionName(itemData.packageName),
...@@ -202,16 +212,8 @@ class GameListFragment : XPageFragment() { ...@@ -202,16 +212,8 @@ class GameListFragment : XPageFragment() {
tx_game_update_notice.visibility = View.VISIBLE tx_game_update_notice.visibility = View.VISIBLE
tx_download_status.visibility = View.GONE tx_download_status.visibility = View.GONE
btn_download_status.visibility = View.GONE btn_download_status.visibility = View.GONE
} else if (AcceleratorUtils.state == BaseService.State.Connected && AcceleratorUtils.game!!.id == itemData.id) { }
btn_uninstall.visibility = View.GONE else {
btn_acc.visibility = View.GONE
btn_acc_stop.visibility = View.VISIBLE
tx_game_update_notice.visibility = View.GONE
tx_download_status.visibility = View.VISIBLE
btn_download_status.visibility = View.GONE
tx_download_size.visibility = View.GONE
tx_status.setText(SysUtils.getAccTimeString(acctime))
} else {
btn_uninstall.visibility = View.GONE btn_uninstall.visibility = View.GONE
btn_acc.visibility = View.VISIBLE btn_acc.visibility = View.VISIBLE
btn_acc_stop.visibility = View.GONE btn_acc_stop.visibility = View.GONE
......
...@@ -5,12 +5,15 @@ import androidx.lifecycle.ViewModel ...@@ -5,12 +5,15 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.ccwangluo.accelerator.model.Game import com.ccwangluo.accelerator.model.Game
import com.ccwangluo.accelerator.model.GameInfo import com.ccwangluo.accelerator.model.GameInfo
import com.ccwangluo.accelerator.utils.AcceleratorUtils
import com.ccwangluo.accelerator.utils.SysUtils import com.ccwangluo.accelerator.utils.SysUtils
import com.ccwangluo.accelerator.utils.http.HttpGo import com.ccwangluo.accelerator.utils.http.HttpGo
import com.xuexiang.xpage.base.XPageFragment import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xutil.app.AppUtils import com.xuexiang.xutil.app.AppUtils
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.net.URLDecoder
import java.net.URLEncoder
class GameListModel : ViewModel() { class GameListModel : ViewModel() {
...@@ -18,10 +21,10 @@ class GameListModel : ViewModel() { ...@@ -18,10 +21,10 @@ class GameListModel : ViewModel() {
val clearList = MutableLiveData<Boolean>() val clearList = MutableLiveData<Boolean>()
fun freshData(xPageFragment: XPageFragment, page: Int) { fun freshData(xPageFragment: XPageFragment, page: Int) {
var packageName = if (AcceleratorUtils.game == null) "" else AcceleratorUtils.game!!.packageName
xPageFragment.lifecycleScope.launch(Dispatchers.IO) { xPageFragment.lifecycleScope.launch(Dispatchers.IO) {
val res = val res =
HttpGo.getSync<Game>("/api/new/game/list?page=${page}&size=20&channelId=${SysUtils.getChannel()}") HttpGo.getSync<Game>("/api/new/game/list?page=${page}&size=20&channelId=${SysUtils.getChannel()}&packageName=${packageName}")
res?.let { res?.let {
it.data?.let { it.data?.let {
clearList.postValue(page == 1) clearList.postValue(page == 1)
......
...@@ -33,9 +33,9 @@ class SplashFragment : XPageFragment() { ...@@ -33,9 +33,9 @@ class SplashFragment : XPageFragment() {
override fun initViews() { override fun initViews() {
TencentLocationManager.getInstance(context) TencentLocationManager.getInstance(context)
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
val map = mutableMapOf<String, Any>() // val map = mutableMapOf<String, Any>()
map.put("packageNameList", SysUtils.getAllAppInfo(context!!)) // map.put("packageNameList", SysUtils.getAllAppInfo(context!!))
HttpGo.postSync<String>("/api/game/addHotGame",map) // HttpGo.postSync<String>("/api/game/addHotGame",map)
delay(1000) delay(1000)
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
openPage(BottomNavigationFragment::class.java, false) openPage(BottomNavigationFragment::class.java, false)
......
...@@ -241,6 +241,7 @@ object AcceleratorUtils : TencentLocationListener { ...@@ -241,6 +241,7 @@ object AcceleratorUtils : TencentLocationListener {
fun stopAccelerator() { fun stopAccelerator() {
Core.stopService() Core.stopService()
game = null
} }
private val shadowsocksConnection = object : ShadowsocksConnection.Callback { private val shadowsocksConnection = object : ShadowsocksConnection.Callback {
......
...@@ -8,6 +8,7 @@ import com.github.shadowsocks.http.HttpConfig ...@@ -8,6 +8,7 @@ import com.github.shadowsocks.http.HttpConfig
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import com.hjq.toast.ToastUtils import com.hjq.toast.ToastUtils
import com.just.agentweb.utils.LogUtils
import com.xuexiang.xutil.XUtil import com.xuexiang.xutil.XUtil
import okhttp3.* import okhttp3.*
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
...@@ -30,7 +31,7 @@ object HttpGo { ...@@ -30,7 +31,7 @@ object HttpGo {
val gson: Gson val gson: Gson
val TAG = HttpGo::class.java.name val TAG = HttpGo::class.java.name
val logger = Logger.getLogger(OkHttpClient::class.java.getName())
init { init {
okHttpClient = OkHttpClient().newBuilder() okHttpClient = OkHttpClient().newBuilder()
.readTimeout(60, TimeUnit.SECONDS)//设置读取超时时间 .readTimeout(60, TimeUnit.SECONDS)//设置读取超时时间
...@@ -41,8 +42,6 @@ object HttpGo { ...@@ -41,8 +42,6 @@ object HttpGo {
.sslSocketFactory(initSSLSocketFactory(), initTrustManager()) .sslSocketFactory(initSSLSocketFactory(), initTrustManager())
.build() .build()
gson = Gson() gson = Gson()
Logger.getLogger(OkHttpClient::class.java.getName()).setLevel(Level.FINE)
} }
fun getClient(): OkHttpClient { fun getClient(): OkHttpClient {
...@@ -58,13 +57,13 @@ object HttpGo { ...@@ -58,13 +57,13 @@ object HttpGo {
LoginUtils.token?.let { LoginUtils.token?.let {
request.addHeader("Authorization", it) request.addHeader("Authorization", it)
} }
Timber.i("%s%s", url, request.toString()) logger.info(url)
val call = okHttpClient.newCall(request.build()) val call = okHttpClient.newCall(request.build())
val response: Response = call.execute() val response: Response = call.execute()
if (response.isSuccessful) { if (response.isSuccessful) {
val type = object : TypeToken<BaseModel<T>>() {}.type val type = object : TypeToken<BaseModel<T>>() {}.type
val string = response.body?.string() val string = response.body?.string()
Timber.i("getSync:" + string.toString()) logger.info("getSync:" + string.toString())
val result: BaseModel<T>? = gson.fromJson(string, type) val result: BaseModel<T>? = gson.fromJson(string, type)
return result return result
} else if (response.code == 401) { } else if (response.code == 401) {
...@@ -99,12 +98,12 @@ object HttpGo { ...@@ -99,12 +98,12 @@ object HttpGo {
LoginUtils.token?.let { LoginUtils.token?.let {
request.addHeader("Authorization", it) request.addHeader("Authorization", it)
} }
Timber.i(request.toString()) logger.info(request.toString())
val call = okHttpClient.newCall(request.build()) val call = okHttpClient.newCall(request.build())
val response: Response = call.execute() val response: Response = call.execute()
if (response.isSuccessful) { if (response.isSuccessful) {
val string = response.body?.string() val string = response.body?.string()
Timber.i("postSync:" + string.toString()) logger.info("postSync:" + string.toString())
val type = object : TypeToken<BaseModel<T>>() {}.type val type = object : TypeToken<BaseModel<T>>() {}.type
val result: BaseModel<T>? = gson.fromJson(string, type) val result: BaseModel<T>? = gson.fromJson(string, type)
return result return result
......
...@@ -36,5 +36,6 @@ object AccVpn { ...@@ -36,5 +36,6 @@ object AccVpn {
val configFile = configFile(context) val configFile = configFile(context)
Timber.d("writeConfig ${configFile.absolutePath}") Timber.d("writeConfig ${configFile.absolutePath}")
configFile.writeText(configContent) configFile.writeText(configContent)
Timber.d("writeConfig readLines ${configContent}")
} }
} }
\ No newline at end of file
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