From bbda756b4b935e3d33f3c127dc50465eddcee0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=A4lz?= Date: Sat, 30 Dec 2017 22:40:49 +0100 Subject: [PATCH] Use first selected sensor id of the plot widget. #12 --- .../de/codefor/karlsruhe/opensense/widget/WidgetHelper.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/de/codefor/karlsruhe/opensense/widget/WidgetHelper.kt b/app/src/main/java/de/codefor/karlsruhe/opensense/widget/WidgetHelper.kt index 760d8a8..bfaaf24 100644 --- a/app/src/main/java/de/codefor/karlsruhe/opensense/widget/WidgetHelper.kt +++ b/app/src/main/java/de/codefor/karlsruhe/opensense/widget/WidgetHelper.kt @@ -71,9 +71,9 @@ object WidgetHelper { internal fun getSensorHistory(context: Context, appWidgetId: Int): Single> { val boxId = loadBoxId(context, appWidgetId) - // TODO make configurable, the following line crashes - //val sensorId = loadSensorIds(context, appWidgetId).first() - val sensorId = "59c67b5ed67eb50011666dc0" + // We keep it really simple here and just use the first selected sensor of this widget + val sensorId = loadSensorIds(context, appWidgetId).firstOrNull() ?: return Single.just(emptyList()) + Log.i("WidgetHelper", "getSensorHistory() boxId: $boxId, sensorId: $sensorId") return getSensorHistory(boxId, sensorId) }