Commit debe43c3 authored by sheteng's avatar sheteng

fix bug

parent 5a2a1032
...@@ -172,6 +172,3 @@ ...@@ -172,6 +172,3 @@
-keep class com.tencent.tpns.baseapi.** {*;} -keep class com.tencent.tpns.baseapi.** {*;}
-keep class com.tencent.tpns.mqttchannel.** {*;} -keep class com.tencent.tpns.mqttchannel.** {*;}
-keep class com.tencent.tpns.dataacquisition.** {*;} -keep class com.tencent.tpns.dataacquisition.** {*;}
-keep class com.tencent.bigdata.baseapi.** {*;} // 1.2.0.1 及以上版本不需要此条配置
-keep class com.tencent.bigdata.mqttchannel.** {*;} // 1.2.0.1 及以上版本不需要此条配置
\ No newline at end of file
...@@ -6,8 +6,6 @@ data class NetState( ...@@ -6,8 +6,6 @@ data class NetState(
var accNetDelay: Int, var accNetDelay: Int,
var delay : Int,
//丢包率 //丢包率
var lossRate: String var lossRate: String
......
...@@ -88,18 +88,18 @@ class AccelertorFragment : XPageFragment() { ...@@ -88,18 +88,18 @@ class AccelertorFragment : XPageFragment() {
binding.netLost2Unit.visibility = View.GONE binding.netLost2Unit.visibility = View.GONE
} }
if (it.delay != -1) { if (state == BaseService.State.Connected) {
binding.netQuality.setText(SysUtils.getnetQuality(it.delay)) binding.netQuality.setText(SysUtils.getnetQuality(it.accNetDelay))
} else {
binding.netQuality.setText(SysUtils.getnetQuality(it.preNetDelay))
} }
binding.activeNetwork.setText(SysUtils.getActiveNet()) binding.activeNetwork.setText(SysUtils.getActiveNet())
}) })
accelertorViewModel.accState.observe(this, { accelertorViewModel.accState.observe(this, {
binding.accStateTx.setText(SysUtils.getAccTimeString(acc_timer)) binding.accStateTx.setText(SysUtils.getAccTimeString(acc_timer))
if (it != state) { state = it
state = it freshData(it)
freshData(it)
}
if (SettingSPUtils.isSmartAccOpen) { if (SettingSPUtils.isSmartAccOpen) {
binding.smartAccOpen.setText("已开启") binding.smartAccOpen.setText("已开启")
binding.smartAccOpen.setTextColor(resources.getColor(R.color.open_acc_enable)) binding.smartAccOpen.setTextColor(resources.getColor(R.color.open_acc_enable))
...@@ -134,10 +134,10 @@ class AccelertorFragment : XPageFragment() { ...@@ -134,10 +134,10 @@ class AccelertorFragment : XPageFragment() {
binding.btnQuick.isEnabled = true binding.btnQuick.isEnabled = true
binding.progressViewCircleSmall.progress = 0F binding.progressViewCircleSmall.progress = 0F
binding.progressViewCircleSmall.postDelayed({ binding.progressViewCircleSmall.postDelayed({
if(state != BaseService.State.Connected){ if (state != BaseService.State.Connected) {
ToastUtils.show("加速失败") ToastUtils.show("加速失败")
} }
},3000) }, 3000)
AcceleratorUtils.startAccelerator(this@AccelertorFragment) AcceleratorUtils.startAccelerator(this@AccelertorFragment)
} }
}) })
...@@ -285,12 +285,7 @@ class AccelertorFragment : XPageFragment() { ...@@ -285,12 +285,7 @@ class AccelertorFragment : XPageFragment() {
fun freshData(state: BaseService.State) { fun freshData(state: BaseService.State) {
if (state == BaseService.State.Connected) { if (state == BaseService.State.Connected) {
binding.gamePicIn1.startAnimation(getDefaultAnim()) startAccSuccess()
binding.accStateTx.visibility = View.VISIBLE
binding.btnQuick.setBackgroundResource(R.mipmap.quick_stop)
if (binding.gamePicOut.background is AnimationDrawable) {
(binding.gamePicOut.background as AnimationDrawable).stop()
}
if (SettingSPUtils.isFirstAccSuccess) { if (SettingSPUtils.isFirstAccSuccess) {
context?.let { context?.let {
CommonDialog(it).setTitle("防止加速掉线") CommonDialog(it).setTitle("防止加速掉线")
...@@ -302,7 +297,6 @@ class AccelertorFragment : XPageFragment() { ...@@ -302,7 +297,6 @@ class AccelertorFragment : XPageFragment() {
} }
} }
binding.gameStart.visibility = View.VISIBLE
} else { } else {
binding.gamePicIn1.clearAnimation() binding.gamePicIn1.clearAnimation()
if (binding.gamePicOut.background is AnimationDrawable) { if (binding.gamePicOut.background is AnimationDrawable) {
...@@ -331,7 +325,18 @@ class AccelertorFragment : XPageFragment() { ...@@ -331,7 +325,18 @@ class AccelertorFragment : XPageFragment() {
fun startAnim() { fun startAnim() {
binding.progressViewCircleSmall.startProgressAnimation() binding.progressViewCircleSmall.startProgressAnimation()
}
fun startAccSuccess(){
if (binding.gameStart.visibility == View.GONE) {
binding.gamePicIn1.startAnimation(getDefaultAnim())
binding.accStateTx.visibility = View.VISIBLE
binding.btnQuick.setBackgroundResource(R.mipmap.quick_stop)
if (binding.gamePicOut.background is AnimationDrawable) {
(binding.gamePicOut.background as AnimationDrawable).stop()
}
binding.gameStart.visibility = View.VISIBLE
}
} }
fun getDefaultAnim(): RotateAnimation { fun getDefaultAnim(): RotateAnimation {
......
package com.ccwangluo.accelerator.ui.news package com.ccwangluo.accelerator.ui.news
import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
...@@ -123,9 +124,11 @@ class NewsObjectFragment : XPageFragment() { ...@@ -123,9 +124,11 @@ class NewsObjectFragment : XPageFragment() {
} }
itemData.isGreat?.let { itemData.isGreat?.let {
if (it) { if (it) {
itemView.findViewById<TextView>(R.id.great_num).setTextColor(Color.parseColor("#FF3B4FBE"))
itemView.findViewById<ImageView>(R.id.great_img) itemView.findViewById<ImageView>(R.id.great_img)
.setBackgroundResource(R.mipmap.icon_praise_bu) .setBackgroundResource(R.mipmap.icon_praise_bu)
} else { } else {
itemView.findViewById<TextView>(R.id.great_num).setTextColor(Color.parseColor("#FFBBBBBB"))
itemView.findViewById<ImageView>(R.id.great_img) itemView.findViewById<ImageView>(R.id.great_img)
.setBackgroundResource(R.mipmap.icon_praise_ga) .setBackgroundResource(R.mipmap.icon_praise_ga)
} }
......
...@@ -53,12 +53,6 @@ object AcceleratorUtils { ...@@ -53,12 +53,6 @@ object AcceleratorUtils {
//游戏 //游戏
var game: GameInfo? = null var game: GameInfo? = null
//加速前延迟
var pre_net = -1
//加速后延迟
var acc_net = -1
var stateListener: (BaseService.State, Long, NetState?) -> Unit = { state, l, net -> var stateListener: (BaseService.State, Long, NetState?) -> Unit = { state, l, net ->
} }
...@@ -71,7 +65,7 @@ object AcceleratorUtils { ...@@ -71,7 +65,7 @@ object AcceleratorUtils {
val res = HttpGo.getSync<Game>("/api/new/game/list?id=1&page=1&size=1") val res = HttpGo.getSync<Game>("/api/new/game/list?id=1&page=1&size=1")
res?.let { res?.let {
game = it.data?.list?.get(0) game = it.data?.list?.get(0)
withContext(Dispatchers.Main){ withContext(Dispatchers.Main) {
callback(true) callback(true)
} }
game?.let { game?.let {
...@@ -93,41 +87,36 @@ object AcceleratorUtils { ...@@ -93,41 +87,36 @@ object AcceleratorUtils {
while (true) { while (true) {
game?.let { game?.let {
val split = it.boosterServer.split(":") val split = it.boosterServer.split(":")
var net = NetState(-1, -1, -1, "100") var net = NetState(-1, -1, "100")
net.delay = NetUtils.tcpPing(split[0], split[1].toInt()).toInt() net.preNetDelay = NetUtils.tcpPing(split[0], split[1].toInt()).toInt()
pre_net = net.delay
if (state == BaseService.State.Connected) { if (state == BaseService.State.Connected) {
val delay = NetUtils.tcpPing(split[0], split[1].toInt(),DataStore.portProxy).toInt() val delay =
acc_net = (delay * 0.5).toInt() NetUtils.tcpPing(split[0], split[1].toInt(), DataStore.portProxy)
.toInt()
net.accNetDelay = (delay * 0.5).toInt()
LoginUtils.getUserHasTimer { LoginUtils.getUserHasTimer {
if (!it) { //没有加速时长关闭服务 if (!it) { //没有加速时长关闭服务
stopAccelerator() stopAccelerator()
} }
} }
net.delay = if (net.delay < delay) net.delay else delay net.accNetDelay =
if (net.accNetDelay > net.preNetDelay && net.preNetDelay != -1) net.preNetDelay else net.accNetDelay
net.lossRate = if (net.accNetDelay == -1) "100" else "0"
} else { } else {
acc_net = -1 net.accNetDelay = -1
net.lossRate = if (net.preNetDelay == -1) "100" else "0"
} }
net.lossRate = if (net.delay == -1) "100" else "0"
net.preNetDelay = pre_net
net.accNetDelay = acc_net
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
stateListener(state, getAccTime(), net) stateListener(state, getAccTime(), net)
} }
} }
delay(2000)
}
}
context.lifecycleScope.launch(Dispatchers.IO) {
while (true) {
stateListener(state, getAccTime(), null)
delay(1000)
} }
} }
} }
fun checkVpn() { fun checkVpn() {
if (AuthManager.Last_ACC_TIme == 0L || System.currentTimeMillis() - AuthManager.Last_ACC_TIme > 2 * 3600 * 1000){ if (AuthManager.Last_ACC_TIme == 0L || System.currentTimeMillis() - AuthManager.Last_ACC_TIme > 2 * 3600 * 1000) {
return return
} }
if (SysUtils.isVpn(context) && state != BaseService.State.Connected) { if (SysUtils.isVpn(context) && state != BaseService.State.Connected) {
......
...@@ -39,33 +39,6 @@ object SysUtils { ...@@ -39,33 +39,6 @@ object SysUtils {
} }
} }
/**
* ping 网络状态
*/
suspend fun getNetPing(ip: String): NetState {
var delay: Int = -1
var lost = ""
val p = Runtime.getRuntime().exec("ping -c 4 ${ip}")
val buf = BufferedReader(InputStreamReader(p.inputStream))
var str: String? = String()
while (buf.readLine().also { str = it } != null) {
str?.let {
if (it.contains("packet loss")) {
val i = it.indexOf("received")
val j = it.indexOf("%")
// System.out.println("丢包率:"+str.substring(j-3, j+1));
lost = it.substring(i + 10, j)
}
if (it.contains("avg")) {
val i = it.indexOf("/", 20)
val j = it.indexOf(".", i)
delay = it.substring(i + 1, j).toInt()
}
}
}
return NetState(-1, -1, delay, lost)
}
/* /*
......
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