Commit 81d8b0d7 authored by wanglei's avatar wanglei

...

parent 283852b9
......@@ -21,6 +21,7 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import java.io.BufferedReader
import java.io.FileReader
import kotlin.math.abs
class BatteryActivity : BaseActivity<ActivityBatteryBinding>() {
......@@ -74,13 +75,19 @@ class BatteryActivity : BaseActivity<ActivityBatteryBinding>() {
binding.tvTechnology.text = BatteryReceiver.technology
binding.tvCapacity.text = "${BatteryReceiver.mAh.toInt()} mAh"
val capacity = BatteryReceiver.mAh.toInt()
binding.tvCapacity.text = "$capacity mAh"
val currentNow = mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW)
binding.tvElectric.text = "${currentNow * 100} mA"
val currentAverage: Int = mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_AVERAGE)
binding.tvCurrentAverage.text = "${currentAverage * 100} mA"
val hm = (capacity.toFloat() / (currentNow * 100f))
binding.tvH.text = abs(hm.toInt()).toString()
binding.tvM.text = abs(((hm - hm.toInt()) * 60).toInt()).toString()
}
fun format(float: Float): String {
......
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