From 8b33fb15e785e0ed1064271120dd2e231517837a Mon Sep 17 00:00:00 2001 From: xiaowusky Date: Mon, 11 Dec 2023 15:32:58 +0800 Subject: [PATCH] =?UTF-8?q?desc:=E6=9C=89=E6=97=A0=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E9=80=9A=E8=BF=87socket=E8=BF=9E=E6=8E=A5=E5=85=AC=E7=BD=918.8?= =?UTF-8?q?.8.8DNS=E6=9C=8D=E5=8A=A1=E6=9D=A5=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E6=94=B6=E5=8F=91=E5=8C=85=E7=9A=84=E5=BF=AB?= =?UTF-8?q?=E6=85=A2=E6=A8=A1=E6=8B=9F=E4=BF=A1=E5=8F=B7=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../watcher/ui/view/CommonTopBar.kt | 19 ++++++++++++++----- .../safetywatcher/watcher/utils/SimHelper.kt | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/view/CommonTopBar.kt b/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/view/CommonTopBar.kt index 9fe7cb2..7c43bc9 100644 --- a/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/view/CommonTopBar.kt +++ b/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/view/CommonTopBar.kt @@ -15,6 +15,7 @@ import android.widget.TextView import androidx.appcompat.content.res.AppCompatResources import com.yinuo.safetywatcher.R import com.yinuo.safetywatcher.databinding.LayoutTopbarBinding +import com.yinuo.safetywatcher.watcher.AppData import com.yinuo.safetywatcher.watcher.utils.BatteryHelper import com.yinuo.safetywatcher.watcher.utils.SimHelper import com.yinuo.safetywatcher.watcher.utils.WifiHelper @@ -95,19 +96,27 @@ class CommonTopBar : LinearLayout { private val simCallback = object : SimHelper.OnSimLevelCallback { override fun onEnable(enable: Boolean) { Log.i(this@CommonTopBar.javaClass.name, "simCallback onEnable = $enable") - mBinding?.fourG?.post { + mBinding?.root?.post { if (enable) { - mBinding?.fourG?.visibility = VISIBLE + if (mBinding?.fourG?.visibility != VISIBLE) { + mBinding?.fourG?.visibility = VISIBLE + } } else { - mBinding?.fourG?.visibility = GONE + if (mBinding?.fourG?.visibility != GONE) { + mBinding?.fourG?.visibility = GONE + } } } } override fun onLevel(level: Int) { Log.i(this@CommonTopBar.javaClass.name, "simCallback onLevel = $level") - mBinding?.fourG?.post { - val showLevel = (level + 1) * 20 + mBinding?.root?.post { + var showLevel = + if (AppData.hasCameraData()) (level / 15 + 1) * 20 else (level + 1) * 20 + if (showLevel > 100) { + showLevel = 100 + } mBinding?.fourG?.setImageLevel(showLevel) } } diff --git a/app/src/main/java/com/yinuo/safetywatcher/watcher/utils/SimHelper.kt b/app/src/main/java/com/yinuo/safetywatcher/watcher/utils/SimHelper.kt index 6f09855..225af95 100644 --- a/app/src/main/java/com/yinuo/safetywatcher/watcher/utils/SimHelper.kt +++ b/app/src/main/java/com/yinuo/safetywatcher/watcher/utils/SimHelper.kt @@ -138,7 +138,7 @@ object SimHelper { val txOffset = totalTxBytes - lastTxBytes Log.i( "setNetStatus", - "txbyte = $totalTxBytes rxbyte = $totalRxBytes timeOffset = $timeOffset" + "txbyte = $txOffset rxbyte = $rxOffset timeOffset = $timeOffset" ) lastTime = currentTimeMillis