[F] Fix initialization order

This commit is contained in:
Azalea Gui
2023-01-24 12:50:03 -05:00
parent 2e0209ce7f
commit 3c27d1ff71
@@ -18,6 +18,7 @@ import org.hydev.wearsync.bles.BluetoothHandler.Companion.ble
import org.hydev.wearsync.bles.decoders.BatteryDecoder
import org.hydev.wearsync.bles.decoders.HeartRateDecoder
import org.hydev.wearsync.bles.decoders.IDecoder
import timber.log.Timber
import java.util.concurrent.atomic.AtomicLong
@@ -50,7 +51,7 @@ class MyService : Service()
private fun add(it: Any) = scope.launch {
runCatching {
println("Adding ${it.javaClass.simpleName} to influxdb")
Timber.d("Adding ${it.javaClass.simpleName} to influxdb")
influx add it
"Recorded ${count.addAndGet(1)} events!".notif()
@@ -61,8 +62,8 @@ class MyService : Service()
override fun onReceive(ctxt: Context, intent: Intent) { add(intent.batteryInfo(bm)) }
}
private val intent = PendingIntent.getActivity(this, 0, intent<MainActivity>(),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
private val intent by lazy { PendingIntent.getActivity(this, 0, intent<MainActivity>(),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) }
private fun String.notif() = startForeground(NOTIF_ID,
NotificationCompat.Builder(this@MyService, NOTIF_CHANNEL_ID)