|
|
|
@ -14,11 +14,11 @@ import android.widget.LinearLayout
|
|
|
|
|
import android.widget.Space
|
|
|
|
|
import android.widget.TextView
|
|
|
|
|
import androidx.appcompat.content.res.AppCompatResources
|
|
|
|
|
import com.common.commonlib.utils.LogUtils
|
|
|
|
|
import com.yinuo.safetywatcher.R
|
|
|
|
|
import com.yinuo.safetywatcher.databinding.LayoutTopbarBinding
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.AppData
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.interfaces.NetworkStateCallback
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.log.LogPrintListener
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.BatteryHelper
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.NetworkHelper
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.trySetCommonBg
|
|
|
|
@ -32,8 +32,6 @@ class CommonTopBar : LinearLayout {
|
|
|
|
|
defStyleAttr
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var logListener : LogPrintListener? = null
|
|
|
|
|
|
|
|
|
|
var mBinding: LayoutTopbarBinding? = null
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
@ -79,16 +77,14 @@ class CommonTopBar : LinearLayout {
|
|
|
|
|
* **/
|
|
|
|
|
private val wifiCallback = object : NetworkStateCallback {
|
|
|
|
|
override fun onEnable(enable: Boolean) {
|
|
|
|
|
Log.i(this@CommonTopBar.javaClass.name, "wifiCallback onEnable = $enable")
|
|
|
|
|
logListener?.log("wifiCallback onEnable = $enable")
|
|
|
|
|
LogUtils.w("wifiCallback onEnable = $enable")
|
|
|
|
|
mBinding?.root?.post {
|
|
|
|
|
mBinding?.wifi?.visibility = if (enable) View.VISIBLE else View.GONE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onLevel(level: Int) {
|
|
|
|
|
Log.i(this@CommonTopBar.javaClass.name, "wifiCallback onLevel = $level")
|
|
|
|
|
logListener?.log("wifiCallback onLevel = $level")
|
|
|
|
|
LogUtils.w("wifiCallback onLevel = $level")
|
|
|
|
|
mBinding?.root?.post {
|
|
|
|
|
mBinding?.wifi?.visibility = if (level > 0) VISIBLE else GONE
|
|
|
|
|
val showLevel = (level + 1) * 20
|
|
|
|
@ -102,16 +98,14 @@ class CommonTopBar : LinearLayout {
|
|
|
|
|
* **/
|
|
|
|
|
private val simCallback = object : NetworkStateCallback {
|
|
|
|
|
override fun onEnable(enable: Boolean) {
|
|
|
|
|
Log.i(this@CommonTopBar.javaClass.name, "simCallback onEnable = $enable")
|
|
|
|
|
logListener?.log("sim enable callback : $enable")
|
|
|
|
|
LogUtils.w("sim enable callback : $enable")
|
|
|
|
|
mBinding?.root?.post {
|
|
|
|
|
mBinding?.fourG?.visibility = if (enable) View.VISIBLE else View.GONE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onLevel(level: Int) {
|
|
|
|
|
Log.i(this@CommonTopBar.javaClass.name, "simCallback onLevel = $level")
|
|
|
|
|
logListener?.log("simCallback onLevel = $level")
|
|
|
|
|
LogUtils.w("simCallback onLevel = $level")
|
|
|
|
|
mBinding?.root?.post {
|
|
|
|
|
var showLevel =
|
|
|
|
|
if (AppData.hasCameraData()) (level / 15 + 1) * 20 else (level + 1) * 20
|
|
|
|
|