Skip to content

Commit

Permalink
Change logging to android.util.Log. CodeforKarlsruhe#12
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaelz committed Dec 28, 2017
1 parent daf04b7 commit 572c291
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package de.codefor.karlsruhe.opensense.data

import android.util.Log
import de.codefor.karlsruhe.opensense.data.boxes.BoxesApi
import de.codefor.karlsruhe.opensense.data.boxes.model.SenseBox
import de.codefor.karlsruhe.opensense.data.boxes.model.SensorHistory
import io.reactivex.Single
import retrofit2.Call
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.moshi.MoshiConverterFactory
import java.util.logging.Logger


object OpenSenseMapService {

val LOG = Logger.getLogger(this::class.java.toString())

private val boxesApi: BoxesApi

init {
Expand All @@ -36,7 +32,7 @@ object OpenSenseMapService {
}

fun getSensorHistory(boxId: String, sensorId: String): Single<List<SensorHistory>> {
LOG.info("returning sensor history, boxId: " + boxId + ", sensorId: " + sensorId)
Log.i("OpenSenseMapService", "getSensorHistory() boxId: $boxId, sensorId: $sensorId")
return boxesApi.getSensorHistory(boxId, sensorId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.content.Context
import android.content.Intent
import android.util.Log
import de.codefor.karlsruhe.opensense.data.OpenSenseMapService
import de.codefor.karlsruhe.opensense.data.boxes.model.SenseBox
import de.codefor.karlsruhe.opensense.data.boxes.model.Sensor
Expand All @@ -13,13 +14,9 @@ import de.codefor.karlsruhe.opensense.widget.base.BaseWidgetConfigurationActivit
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.util.logging.Logger
import kotlin.reflect.KClass

object WidgetHelper {

val LOG = Logger.getLogger(this::class.java.toString())

private val PREFS_NAME = "de.codefor.karlsruhe.opensense.widget"
private val PREF_BOX_ID = "box_id_"
private val PREF_SENSOR_IDS = "sensor_ids_"
Expand Down Expand Up @@ -77,7 +74,7 @@ object WidgetHelper {
// TODO make configurable, the following line crashes
//val sensorId = loadSensorIds(context, appWidgetId).first()
val sensorId = "59c67b5ed67eb50011666dc0"
LOG.info("sensor history requested, boxId: " + boxId + ", sensorId: " + sensorId)
Log.i("WidgetHelper", "getSensorHistory() boxId: $boxId, sensorId: $sensorId")
return getSensorHistory(boxId, sensorId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import de.codefor.karlsruhe.opensense.widget.WidgetHelper
import java.util.logging.Logger

/**
* Implementation of default widget containing a maximum of five sensor data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package de.codefor.karlsruhe.opensense.widget.onevalue

import android.appwidget.AppWidgetManager
import android.content.Context
import android.util.Log
import android.view.View
import android.widget.RemoteViews
import de.codefor.karlsruhe.opensense.R
import de.codefor.karlsruhe.opensense.widget.WidgetHelper
import de.codefor.karlsruhe.opensense.widget.base.BaseWidget
import java.util.logging.Logger


class OneValueWidget : BaseWidget() {
Expand All @@ -16,9 +16,6 @@ class OneValueWidget : BaseWidget() {
}

companion object {

val LOG = Logger.getLogger(this::class.java.toString())

fun update(context: Context, appWidgetId: Int, appWidgetManager: AppWidgetManager) {
val views = RemoteViews(context.packageName, R.layout.one_value_widget)
//Show progress bar, hide refresh button
Expand All @@ -32,7 +29,7 @@ class OneValueWidget : BaseWidget() {
WidgetHelper.getSenseBox(context, appWidgetId).subscribe({ senseBox ->
val sensorIds = WidgetHelper.loadSensorIds(context, appWidgetId)
val sensor = senseBox.sensors?.first { (id) -> id == sensorIds.first() }
LOG.info(senseBox.toString() + sensorIds.toString() + sensor.toString())
Log.i("OneValueWidget", "$senseBox, ${sensor.toString()}")
views.apply {
//Show refresh button, hide progress bar
setViewVisibility(R.id.one_value_widget_refresh_button, View.VISIBLE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
import android.widget.RemoteViews
import de.codefor.karlsruhe.opensense.R
import android.util.Log
import android.view.View
import android.widget.RemoteViews
import com.androidplot.util.PixelUtils
import com.androidplot.xy.*
import com.androidplot.xy.LineAndPointFormatter
import com.androidplot.xy.SimpleXYSeries
import com.androidplot.xy.XYGraphWidget
import com.androidplot.xy.XYPlot
import de.codefor.karlsruhe.opensense.R
import de.codefor.karlsruhe.opensense.data.boxes.model.SensorHistory
import de.codefor.karlsruhe.opensense.widget.WidgetHelper
import de.codefor.karlsruhe.opensense.widget.base.BaseWidget
import java.util.logging.Logger
import com.androidplot.xy.LineAndPointFormatter

class PlotWidget : BaseWidget() {

Expand All @@ -23,10 +25,6 @@ class PlotWidget : BaseWidget() {
}

companion object {

val LOG = Logger.getLogger(this::class.java.toString())


fun update(context: Context, appWidgetId: Int, appWidgetManager: AppWidgetManager) {
val views = RemoteViews(context.packageName, R.layout.plot_widget)

Expand Down Expand Up @@ -94,7 +92,7 @@ class PlotWidget : BaseWidget() {

plot.layout(0, 0, w, h)

LOG.info("sensorHistory size: " + sensorHist.size + ", data: " + sensorHist.toString())
Log.i("PlotWidget", "sensorHistory size: ${sensorHist.size}, data: $sensorHist")

val history = mutableListOf<Double>()

Expand Down

0 comments on commit 572c291

Please sign in to comment.