|
@@ -5,11 +5,11 @@ import android.app.PendingIntent
|
|
|
import android.app.Service
|
|
|
import android.appwidget.AppWidgetManager
|
|
|
import android.content.Intent
|
|
|
+import android.graphics.Color
|
|
|
import android.os.IBinder
|
|
|
import android.util.Log
|
|
|
import android.widget.RemoteViews
|
|
|
import com.android.volley.Request
|
|
|
-import com.android.volley.Response
|
|
|
import com.android.volley.toolbox.StringRequest
|
|
|
import com.android.volley.toolbox.Volley
|
|
|
|
|
@@ -22,23 +22,31 @@ class UpdateWidgetService : Service() {
|
|
|
|
|
|
val remoteViews = RemoteViews(this.applicationContext.packageName, R.layout.home_temp_app_widget )
|
|
|
|
|
|
+ for (widgetId in allWidgetIds!!) {
|
|
|
+ Log.i("SERVICE", "Set gray")
|
|
|
+ remoteViews.setTextColor(R.id.appwidget_text, Color.DKGRAY)
|
|
|
+ appWidgetManager.updateAppWidget(widgetId, remoteViews)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
val queue = Volley.newRequestQueue(this)
|
|
|
- val url = "http://chef.maya.se/info/curr_temp.php"
|
|
|
+ val url = "http://www.flacksta.com/info/curr_temp.php"
|
|
|
|
|
|
// Request a string response from the provided URL.
|
|
|
val stringRequest = StringRequest(
|
|
|
Request.Method.GET, url,
|
|
|
- Response.Listener<String> { response ->
|
|
|
+ { response ->
|
|
|
Log.i("SERVICE", "Response is: $response")
|
|
|
- for (widgetId in allWidgetIds!!) {
|
|
|
+ for (widgetId in allWidgetIds) {
|
|
|
remoteViews.setTextViewText(R.id.appwidget_text,"$response \u2103")
|
|
|
+ remoteViews.setTextColor(R.id.appwidget_text, Color.BLACK)
|
|
|
appWidgetManager.updateAppWidget(widgetId, remoteViews)
|
|
|
}
|
|
|
},
|
|
|
- Response.ErrorListener {
|
|
|
+ {
|
|
|
Log.i("SERVICE", "That didn't work!" )
|
|
|
- for (widgetId in allWidgetIds!!) {
|
|
|
- remoteViews.setTextViewText(R.id.appwidget_text,"ERR")
|
|
|
+ for (widgetId in allWidgetIds) {
|
|
|
+ remoteViews.setTextViewText(R.id.appwidget_text,"Error")
|
|
|
appWidgetManager.updateAppWidget(widgetId, remoteViews)
|
|
|
}
|
|
|
}
|
|
@@ -46,7 +54,7 @@ class UpdateWidgetService : Service() {
|
|
|
|
|
|
queue.add(stringRequest)
|
|
|
|
|
|
- for (widgetId in allWidgetIds!!) {
|
|
|
+ for (widgetId in allWidgetIds) {
|
|
|
|
|
|
val clickIntent = Intent(this.applicationContext,HomeTempAppWidget::class.java )
|
|
|
clickIntent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
|