three new parameters in wind rose window

pull/1/head
Mateusz Lubecki 2020-12-31 23:58:32 +01:00
rodzic 2416c708f4
commit 43c9ddc45d
10 zmienionych plików z 92 dodań i 7 usunięć

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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);

Wyświetl plik

@ -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

Wyświetl plik

@ -168,6 +168,51 @@
android:orientation="vertical"
app:layout_constraintGuide_percent="0.61" />
<TextView
android:id="@+id/textViewWindRoseMaxHourGust"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="245dp"
android:text="@string/max_1h_gust"
android:textAlignment="center"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageViewWindRose"/>
<TextView
android:id="@+id/textViewWindRoseMinHourSpeed"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_marginBottom="218dp"
android:text="@string/min_1h_avg"
android:textAlignment="center"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewWindRoseMaxHourGust"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textViewWindRosePressure"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_marginBottom="184dp"
android:text="@string/qnh"
android:textAlignment="center"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewWindRoseMinHourSpeed"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>

Wyświetl plik

@ -24,7 +24,7 @@
<string name="archive_data">Archival Data</string>
<string name="export_from">Export From</string>
<string name="time_scale">Time Scale</string>
<string name="mean_value">Mean</string>
<string name="mean_value">Average</string>
<string name="max_value">Maximum Value</string>
<string name="show_previous">Show previous</string>
<string name="hours">Hours</string>
@ -46,5 +46,6 @@
<string name="wind_direction_short">Direction</string>
<string name="temperature_short">Tempr</string>
<string name="degress">Degrees</string>
<string name="max_1h_gust">Maximum gust last 1h</string>
<string name="max_1h_gust">Maximum gust in last 1h</string>
<string name="min_1h_avg">Minimum average in last 1h</string>
</resources>

Wyświetl plik

@ -47,4 +47,5 @@
<string name="temperature_short">-</string>
<string name="degress">-</string>
<string name="max_1h_gust">-</string>
<string name="min_1h_avg">-</string>
</resources>

Wyświetl plik

@ -47,5 +47,6 @@
<string name="temperature_short">-</string>
<string name="degress">-</string>
<string name="max_1h_gust">-</string>
<string name="min_1h_avg">-</string>
</resources>

Wyświetl plik

@ -46,5 +46,6 @@
<string name="wind_direction_short">Kierunek</string>
<string name="temperature_short">Tempr</string>
<string name="degress">Stopni</string>
<string name="max_1h_gust">Maks poryw ost godzina</string>
<string name="max_1h_gust">Maks poryw w ost godzinie</string>
<string name="min_1h_avg">Min prędkość w ost godzinie</string>
</resources>

Wyświetl plik

@ -46,5 +46,6 @@
<string name="wind_direction_short">Kierunek</string>
<string name="temperature_short">Tempr</string>
<string name="degress">Stopni</string>
<string name="max_1h_gust">Maks poryw ost godzina</string>
<string name="max_1h_gust">Maks poryw w ost godzinie</string>
<string name="min_1h_avg">Min prędkość w ost godzinie</string>
</resources>

Wyświetl plik

@ -23,7 +23,7 @@
<string name="archive_data">Archival Data</string>
<string name="export_from">Export From</string>
<string name="time_scale">Time Scale</string>
<string name="mean_value">Mean</string>
<string name="mean_value">Average</string>
<string name="max_value">Maximum Value</string>
<string name="show_previous">Show previous</string>
<string name="hours">Hours</string>
@ -50,5 +50,6 @@
<string name="temperature_short">Tempr</string>
<string name="degress">Degrees</string>
<string name="degrees_sign" translatable="false">°</string>
<string name="max_1h_gust">Maximum gust last 1h</string>
<string name="max_1h_gust">Maximum gust in last 1h</string>
<string name="min_1h_avg">Minimum average in last 1h</string>
</resources>