[F] Fix initialization order
This commit is contained in:
@@ -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.BatteryDecoder
|
||||||
import org.hydev.wearsync.bles.decoders.HeartRateDecoder
|
import org.hydev.wearsync.bles.decoders.HeartRateDecoder
|
||||||
import org.hydev.wearsync.bles.decoders.IDecoder
|
import org.hydev.wearsync.bles.decoders.IDecoder
|
||||||
|
import timber.log.Timber
|
||||||
import java.util.concurrent.atomic.AtomicLong
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
|
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ class MyService : Service()
|
|||||||
|
|
||||||
private fun add(it: Any) = scope.launch {
|
private fun add(it: Any) = scope.launch {
|
||||||
runCatching {
|
runCatching {
|
||||||
println("Adding ${it.javaClass.simpleName} to influxdb")
|
Timber.d("Adding ${it.javaClass.simpleName} to influxdb")
|
||||||
influx add it
|
influx add it
|
||||||
|
|
||||||
"Recorded ${count.addAndGet(1)} events!".notif()
|
"Recorded ${count.addAndGet(1)} events!".notif()
|
||||||
@@ -61,8 +62,8 @@ class MyService : Service()
|
|||||||
override fun onReceive(ctxt: Context, intent: Intent) { add(intent.batteryInfo(bm)) }
|
override fun onReceive(ctxt: Context, intent: Intent) { add(intent.batteryInfo(bm)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private val intent = PendingIntent.getActivity(this, 0, intent<MainActivity>(),
|
private val intent by lazy { PendingIntent.getActivity(this, 0, intent<MainActivity>(),
|
||||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) }
|
||||||
|
|
||||||
private fun String.notif() = startForeground(NOTIF_ID,
|
private fun String.notif() = startForeground(NOTIF_ID,
|
||||||
NotificationCompat.Builder(this@MyService, NOTIF_CHANNEL_ID)
|
NotificationCompat.Builder(this@MyService, NOTIF_CHANNEL_ID)
|
||||||
|
|||||||
Reference in New Issue
Block a user