diff --git a/app/src/main/java/cc/pogoda/mobile/pogodacc/activity/StationDetailsWindRoseActivity.java b/app/src/main/java/cc/pogoda/mobile/pogodacc/activity/StationDetailsWindRoseActivity.java index da697e0..a401ccb 100644 --- a/app/src/main/java/cc/pogoda/mobile/pogodacc/activity/StationDetailsWindRoseActivity.java +++ b/app/src/main/java/cc/pogoda/mobile/pogodacc/activity/StationDetailsWindRoseActivity.java @@ -35,15 +35,19 @@ public class StationDetailsWindRoseActivity extends AppCompatActivity { station = (WeatherStation) getIntent().getSerializableExtra("station"); + // find all elements in the xml layout file and set the references in a holding object elements = new StationWindRoseActElements(); elements.windArrow = findViewById(R.id.imageViewWindRoseArrow); elements.windSpeed = findViewById(R.id.textViewWindRoseWindSpeed); elements.windGusts = findViewById(R.id.textViewWindRoseWindGusts); elements.windDirection = findViewById(R.id.textViewWindRoseWindDirection); elements.temperature = findViewById(R.id.textViewWindRoseTemperatura); + elements.maxGust = findViewById(R.id.textViewWindRoseMaxHourGust); + elements.minAverage = findViewById(R.id.textViewWindRoseMinHourSpeed); + elements.pressure = findViewById(R.id.textViewWindRosePressure); elements.setActivity(this); - // create the hanlder which will update the screen in background + // create the handler which will update the screen in background handler = new Handler(); SummaryDao summary_dao = new SummaryDao(); @@ -58,6 +62,7 @@ public class StationDetailsWindRoseActivity extends AppCompatActivity { updater = new StationDetailsValuesUpdater(elements, handler, station.getSystemName()); if (handler != null && updater != null) { + // start the handler to update the wind rose activity in background handler.post(updater); } @@ -66,6 +71,7 @@ public class StationDetailsWindRoseActivity extends AppCompatActivity { @Override protected void onStop() { + // remove and stop background callback if (handler != null && updater != null) { handler.removeCallbacks(updater); } diff --git a/app/src/main/java/cc/pogoda/mobile/pogodacc/activity/updater/StationDetailsValuesUpdater.java b/app/src/main/java/cc/pogoda/mobile/pogodacc/activity/updater/StationDetailsValuesUpdater.java index 7bcba29..51ecc26 100644 --- a/app/src/main/java/cc/pogoda/mobile/pogodacc/activity/updater/StationDetailsValuesUpdater.java +++ b/app/src/main/java/cc/pogoda/mobile/pogodacc/activity/updater/StationDetailsValuesUpdater.java @@ -7,6 +7,9 @@ import cc.pogoda.mobile.pogodacc.type.StationActivityElements; import cc.pogoda.mobile.pogodacc.type.StationSummaryActElements; import cc.pogoda.mobile.pogodacc.type.web.Summary; +/** + * Class used to update the content of Wind Rose Activity + */ public class StationDetailsValuesUpdater implements Runnable { StationActivityElements elements = null; @@ -35,8 +38,10 @@ public class StationDetailsValuesUpdater implements Runnable { return; } else { + // get the current data from the Web Service station_summary = dao.getStationSummary(station_name); + // null check is done inside this call elements.updateFromSummary(station_summary); handler.postDelayed(this, 90000); diff --git a/app/src/main/java/cc/pogoda/mobile/pogodacc/type/StationWindRoseActElements.java b/app/src/main/java/cc/pogoda/mobile/pogodacc/type/StationWindRoseActElements.java index 0663255..e3e98f2 100644 --- a/app/src/main/java/cc/pogoda/mobile/pogodacc/type/StationWindRoseActElements.java +++ b/app/src/main/java/cc/pogoda/mobile/pogodacc/type/StationWindRoseActElements.java @@ -5,6 +5,8 @@ import android.content.Context; import android.widget.ImageView; import android.widget.TextView; +import org.w3c.dom.Text; + import cc.pogoda.mobile.pogodacc.R; import cc.pogoda.mobile.pogodacc.type.web.Summary; @@ -22,6 +24,14 @@ public class StationWindRoseActElements implements StationActivityElements { public TextView pressure; + public TextView maxGust; + + /** + * This field is named 'minAverage' but in UX it is described as minimal wind speed which is + * not exactly precise. + */ + public TextView minAverage; + Activity activity; public StationWindRoseActElements() { @@ -60,6 +70,19 @@ public class StationWindRoseActElements implements StationActivityElements { temperature.setText(activity.getResources().getString(R.string.temperature_short) + '\n' + String.format("%.1f", s.avg_temperature) + "°C"); } + + if (pressure != null) { + pressure.setText(activity.getResources().getString(R.string.qnh) + ": " + String.format("%d hPa", s.qnh)); + } + + if (maxGust != null) { + maxGust.setText(activity.getResources().getString(R.string.max_1h_gust) + ": " + s.hour_gusts + "m/s"); + } + + if (minAverage != null) { + minAverage.setText(activity.getResources().getString(R.string.min_1h_avg) + ": " + s.hour_min_average_speed + "m/s"); + + } } @Override diff --git a/app/src/main/res/layout/activity_station_details_wind_rose.xml b/app/src/main/res/layout/activity_station_details_wind_rose.xml index 11bc274..ade47df 100644 --- a/app/src/main/res/layout/activity_station_details_wind_rose.xml +++ b/app/src/main/res/layout/activity_station_details_wind_rose.xml @@ -168,6 +168,51 @@ android:orientation="vertical" app:layout_constraintGuide_percent="0.61" /> + + + + + + diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml index fd34e6d..0f8541d 100644 --- a/app/src/main/res/values-en-rUS/strings.xml +++ b/app/src/main/res/values-en-rUS/strings.xml @@ -24,7 +24,7 @@ Archival Data Export From Time Scale - Mean + Average Maximum Value Show previous Hours @@ -46,5 +46,6 @@ Direction Tempr Degrees - Maximum gust last 1h + Maximum gust in last 1h + Minimum average in last 1h \ No newline at end of file diff --git a/app/src/main/res/values-lv-rLV/strings.xml b/app/src/main/res/values-lv-rLV/strings.xml index 2df51ec..6dfce9c 100644 --- a/app/src/main/res/values-lv-rLV/strings.xml +++ b/app/src/main/res/values-lv-rLV/strings.xml @@ -47,4 +47,5 @@ - - - + - \ No newline at end of file diff --git a/app/src/main/res/values-lv/strings.xml b/app/src/main/res/values-lv/strings.xml index ace1c68..a50d64c 100644 --- a/app/src/main/res/values-lv/strings.xml +++ b/app/src/main/res/values-lv/strings.xml @@ -47,5 +47,6 @@ - - - + - \ No newline at end of file diff --git a/app/src/main/res/values-pl-rPL/strings.xml b/app/src/main/res/values-pl-rPL/strings.xml index 8feda40..0b56b1b 100644 --- a/app/src/main/res/values-pl-rPL/strings.xml +++ b/app/src/main/res/values-pl-rPL/strings.xml @@ -46,5 +46,6 @@ Kierunek Tempr Stopni - Maks poryw ost godzina + Maks poryw w ost godzinie + Min prędkość w ost godzinie \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 7bc444b..99b4d36 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -46,5 +46,6 @@ Kierunek Tempr Stopni - Maks poryw ost godzina + Maks poryw w ost godzinie + Min prędkość w ost godzinie \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2747cf9..496240d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,7 +23,7 @@ Archival Data Export From Time Scale - Mean + Average Maximum Value Show previous Hours @@ -50,5 +50,6 @@ Tempr Degrees ° - Maximum gust last 1h + Maximum gust in last 1h + Minimum average in last 1h \ No newline at end of file