kopia lustrzana https://github.com/SP8EBC/MeteoSystem
hiding unsupported parameters
rodzic
6bb505db54
commit
5a91b95eb2
|
@ -48,7 +48,7 @@ public class StationDetailsSummaryActivity extends AppCompatActivity {
|
|||
|
||||
summary = summary_dao.getStationSummary(station.getSystemName());
|
||||
|
||||
elems.updateFromSummary(summary);
|
||||
elems.updateFromSummary(summary, station.getAvailableParameters());
|
||||
|
||||
handler = new Handler();
|
||||
updater = new StationDetailsValuesUpdater(elems, handler, station.getSystemName());
|
||||
|
|
|
@ -56,7 +56,7 @@ public class StationDetailsWindRoseActivity extends AppCompatActivity {
|
|||
summary = summary_dao.getStationSummary(station.getSystemName());
|
||||
|
||||
// update parameters (like turn the wind direction arrow)
|
||||
elements.updateFromSummary(summary);
|
||||
elements.updateFromSummary(summary, station.getAvailableParameters());
|
||||
|
||||
handler = new Handler();
|
||||
updater = new StationDetailsValuesUpdater(elements, handler, station.getSystemName());
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.pogoda.mobile.pogodacc.dao;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import cc.pogoda.mobile.pogodacc.type.AvailableParameters;
|
||||
import cc.pogoda.mobile.pogodacc.type.WeatherStation;
|
||||
import cc.pogoda.mobile.pogodacc.type.web.ListOfAllStations;
|
||||
import cc.pogoda.mobile.pogodacc.type.web.StationDefinition;
|
||||
|
@ -64,6 +65,9 @@ public class AllStationsDao {
|
|||
elem.setStationNameTextColor(def.stationNameTextColour);
|
||||
elem.setImageAlign(def.backgroundJpgAlign);
|
||||
|
||||
AvailableParameters availableParameters = AvailableParameters.fromStation(def);
|
||||
elem.setAvailableParameters(availableParameters);
|
||||
|
||||
out.add(elem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cc.pogoda.mobile.pogodacc.type;
|
||||
|
||||
import cc.pogoda.mobile.pogodacc.type.web.StationDefinition;
|
||||
|
||||
public class AvailableParameters {
|
||||
|
||||
public boolean windSpeed;
|
||||
|
@ -15,4 +17,42 @@ public class AvailableParameters {
|
|||
public boolean qnh;
|
||||
|
||||
public boolean humidity;
|
||||
|
||||
public boolean rain;
|
||||
|
||||
public AvailableParameters() {
|
||||
windSpeed = false;
|
||||
windGusts = false;
|
||||
windDirection = false;
|
||||
airTemperature = false;
|
||||
qnh = false;
|
||||
humidity = false;
|
||||
waterTemperature = false;
|
||||
rain = false;
|
||||
}
|
||||
|
||||
public static AvailableParameters fromStation(StationDefinition s) {
|
||||
AvailableParameters out = new AvailableParameters();
|
||||
|
||||
if (s.hasHumidity) {
|
||||
out.humidity = true;
|
||||
}
|
||||
|
||||
if (s.hasWind) {
|
||||
out.windDirection = true;
|
||||
out.windGusts = true;
|
||||
out.windSpeed = true;
|
||||
}
|
||||
|
||||
if (s.hasQnh) {
|
||||
out.qnh = true;
|
||||
}
|
||||
|
||||
if (s.hasRain) {
|
||||
out.rain = true;
|
||||
}
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import cc.pogoda.mobile.pogodacc.type.web.Summary;
|
|||
*/
|
||||
public interface StationActivityElements {
|
||||
|
||||
public void updateFromSummary(Summary s);
|
||||
public void updateFromSummary(Summary s, AvailableParameters enabledForStation);
|
||||
|
||||
public void setActivity(Activity act);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.threeten.bp.ZonedDateTime;
|
|||
import org.threeten.bp.temporal.ChronoUnit;
|
||||
|
||||
import cc.pogoda.mobile.pogodacc.R;
|
||||
import cc.pogoda.mobile.pogodacc.type.web.QualityFactor;
|
||||
import cc.pogoda.mobile.pogodacc.type.web.Summary;
|
||||
|
||||
public class StationSummaryActElements implements StationActivityElements {
|
||||
|
@ -69,7 +70,7 @@ public class StationSummaryActElements implements StationActivityElements {
|
|||
return out;
|
||||
}
|
||||
|
||||
public void updateFromSummary(Summary s) {
|
||||
public void updateFromSummary(Summary s, AvailableParameters enabledForStation) {
|
||||
|
||||
if (s == null) {
|
||||
// print a message in case there is no data available
|
||||
|
@ -107,23 +108,47 @@ public class StationSummaryActElements implements StationActivityElements {
|
|||
message.setTextColor(Color.argb(0xFF, 0xFF, 0x0, 0x0));
|
||||
}
|
||||
|
||||
if (wind_speed_val != null)
|
||||
if (!s.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE) && enabledForStation.windSpeed) {
|
||||
wind_speed_val.setText(String.format("%.1f m/s", s.average_speed));
|
||||
}
|
||||
else {
|
||||
wind_speed_val.setText("---");
|
||||
}
|
||||
|
||||
if (wind_gusts_val != null)
|
||||
if (!s.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE) && enabledForStation.windGusts) {
|
||||
wind_gusts_val.setText(String.format("%.1f m/s", s.gusts));
|
||||
}
|
||||
else {
|
||||
wind_gusts_val.setText("---");
|
||||
}
|
||||
|
||||
if (wind_dir_val != null)
|
||||
if (!s.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE) && enabledForStation.windDirection) {
|
||||
wind_dir_val.setText(this.convertDegreesToDir(s.direction));
|
||||
}
|
||||
else {
|
||||
wind_dir_val.setText("---");
|
||||
}
|
||||
|
||||
if (temperature_val != null)
|
||||
if (!s.temperature_qf_native.equals(QualityFactor.NOT_AVALIABLE)) {
|
||||
temperature_val.setText(String.format("%.1f °C", s.avg_temperature));
|
||||
}
|
||||
else {
|
||||
temperature_val.setText("---");
|
||||
}
|
||||
|
||||
if (qnh_val != null)
|
||||
if (!s.qnh_qf_native.equals(QualityFactor.NOT_AVALIABLE) && enabledForStation.qnh) {
|
||||
qnh_val.setText(String.format("%d hPa", s.qnh));
|
||||
}
|
||||
else {
|
||||
qnh_val.setText("---");
|
||||
}
|
||||
|
||||
if (humidity_val != null)
|
||||
if (!s.humidity_qf_native.equals(QualityFactor.NOT_AVALIABLE) && enabledForStation.humidity) {
|
||||
humidity_val.setText(String.format("%d %%", s.humidity));
|
||||
}
|
||||
else {
|
||||
humidity_val.setText("---");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public class StationWindRoseActElements implements StationActivityElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateFromSummary(Summary s) {
|
||||
public void updateFromSummary(Summary s, AvailableParameters enabledForStation) {
|
||||
|
||||
// data to be displayed
|
||||
Summary data;
|
||||
|
@ -75,8 +75,7 @@ public class StationWindRoseActElements implements StationActivityElements {
|
|||
|
||||
// set the flag to true to show '---' or 'no data' instead of zeros
|
||||
no_data = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
data = s;
|
||||
|
||||
// convert the integer with unix epoch timestamp to LocalDateTime in current system Time Zone
|
||||
|
@ -97,55 +96,48 @@ public class StationWindRoseActElements implements StationActivityElements {
|
|||
// check if wind data is avaliable in the input data set
|
||||
if (!no_data && !data.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE)) {
|
||||
windArrow.setRotation(data.direction - 225.0f);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// if now wind data is avaliable in the input set move the arrow
|
||||
// to point towards the N
|
||||
windArrow.setRotation(180.0f - 225.0f);
|
||||
}
|
||||
|
||||
if (!no_data && !data.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE)) {
|
||||
windSpeed.setText(activity.getResources().getString(R.string.mean_value) + '\n' + data.average_speed + "m/s");
|
||||
}
|
||||
else {
|
||||
windSpeed.setText(activity.getResources().getString(R.string.mean_value) + '\n' + "---");
|
||||
windSpeed.setText(activity.getResources().getString(R.string.mean_value) + '\n' + data.average_speed + "m/s");
|
||||
} else {
|
||||
windSpeed.setText(activity.getResources().getString(R.string.mean_value) + '\n' + "---");
|
||||
}
|
||||
|
||||
if (!no_data && !data.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE)) {
|
||||
windGusts.setText(activity.getResources().getString(R.string.wind_gust_short) + '\n' + data.gusts + "m/s");
|
||||
}
|
||||
else {
|
||||
windGusts.setText(activity.getResources().getString(R.string.wind_gust_short) + '\n' + "---");
|
||||
windGusts.setText(activity.getResources().getString(R.string.wind_gust_short) + '\n' + data.gusts + "m/s");
|
||||
} else {
|
||||
windGusts.setText(activity.getResources().getString(R.string.wind_gust_short) + '\n' + "---");
|
||||
|
||||
}
|
||||
|
||||
if (!no_data && !data.wind_qf_native.equals(QualityFactor.NOT_AVALIABLE)) {
|
||||
windDirection.setText(activity.getResources().getString(R.string.wind_direction_short) + '\n' + data.direction + activity.getResources().getString(R.string.degrees_sign));
|
||||
}
|
||||
else {
|
||||
windDirection.setText(activity.getResources().getString(R.string.wind_direction_short) + '\n' + "---");
|
||||
windDirection.setText(activity.getResources().getString(R.string.wind_direction_short) + '\n' + data.direction + activity.getResources().getString(R.string.degrees_sign));
|
||||
} else {
|
||||
windDirection.setText(activity.getResources().getString(R.string.wind_direction_short) + '\n' + "---");
|
||||
}
|
||||
|
||||
// check if temperature is avaliable in input data set
|
||||
if (!no_data && !data.temperature_qf_native.equals(QualityFactor.NOT_AVALIABLE)) {
|
||||
temperature.setText(activity.getResources().getString(R.string.temperature_short) + '\n' + String.format("%.1f", data.avg_temperature) + "°C");
|
||||
}
|
||||
else {
|
||||
temperature.setText(activity.getResources().getString(R.string.temperature_short) + '\n' + "---");
|
||||
temperature.setText(activity.getResources().getString(R.string.temperature_short) + '\n' + String.format("%.1f", data.avg_temperature) + "°C");
|
||||
} else {
|
||||
temperature.setText(activity.getResources().getString(R.string.temperature_short) + '\n' + "---");
|
||||
}
|
||||
|
||||
if (!no_data && !old_data) {
|
||||
pressure.setText(activity.getResources().getString(R.string.qnh) + ": " + String.format("%d hPa", data.qnh));
|
||||
maxGust.setText(activity.getResources().getString(R.string.max_1h_gust) + ": " + data.hour_gusts + "m/s");
|
||||
minAverage.setText(activity.getResources().getString(R.string.min_1h_avg) + ": " + data.hour_min_average_speed + "m/s");
|
||||
}
|
||||
else if (!no_data && old_data) {
|
||||
} else if (!no_data && old_data) {
|
||||
maxGust.setText(activity.getResources().getString(R.string.warning));
|
||||
maxGust.setTextColor(Color.RED);
|
||||
minAverage.setText(activity.getResources().getString(R.string.station_doesnt_transmit));
|
||||
pressure.setText(activity.getResources().getString(R.string.for_longer_than_2_hours));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
maxGust.setText(activity.getResources().getString(R.string.no_data));
|
||||
maxGust.setTextColor(Color.RED);
|
||||
minAverage.setText("");
|
||||
|
|
|
@ -84,6 +84,14 @@ public class WeatherStation implements Serializable {
|
|||
this.imageAlign = imageAlign;
|
||||
}
|
||||
|
||||
public AvailableParameters getAvailableParameters() {
|
||||
return availableParameters;
|
||||
}
|
||||
|
||||
public void setAvailableParameters(AvailableParameters availableParameters) {
|
||||
this.availableParameters = availableParameters;
|
||||
}
|
||||
|
||||
String systemName;
|
||||
|
||||
String displayedName;
|
||||
|
@ -102,5 +110,7 @@ public class WeatherStation implements Serializable {
|
|||
|
||||
float lon;
|
||||
|
||||
AvailableParameters availableParameters;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -65,4 +65,5 @@
|
|||
<string name="wind_direction_plots">Wind Direction Plot</string>
|
||||
<string name="temperature_plot">Temperature Plot</string>
|
||||
<string name="humidity_plot">Humidity Plot</string>
|
||||
<string name="station_doesnt_measure">The station doesn\'t measure this parameter</string>
|
||||
</resources>
|
|
@ -65,4 +65,5 @@
|
|||
<string name="wind_direction_plots">-</string>
|
||||
<string name="temperature_plot">-</string>
|
||||
<string name="humidity_plot">-</string>
|
||||
<string name="station_doesnt_measure">-</string>
|
||||
</resources>
|
|
@ -65,5 +65,6 @@
|
|||
<string name="wind_direction_plots">-</string>
|
||||
<string name="temperature_plot">-</string>
|
||||
<string name="humidity_plot">-</string>
|
||||
<string name="station_doesnt_measure">-</string>
|
||||
|
||||
</resources>
|
|
@ -65,4 +65,5 @@
|
|||
<string name="wind_direction_plots">Kierunek Wiatru</string>
|
||||
<string name="temperature_plot">Temperatura</string>
|
||||
<string name="humidity_plot">Wilgotność</string>
|
||||
<string name="station_doesnt_measure">Stacja nie mierzy tego parametru</string>
|
||||
</resources>
|
|
@ -65,4 +65,5 @@
|
|||
<string name="wind_direction_plots">Kierunek Wiatru</string>
|
||||
<string name="temperature_plot">Temperatura</string>
|
||||
<string name="humidity_plot">Wilgotność</string>
|
||||
<string name="station_doesnt_measure">Stacja nie mierzy tego parametru</string>
|
||||
</resources>
|
|
@ -69,4 +69,5 @@
|
|||
<string name="wind_direction_plots">Wind Direction Plot</string>
|
||||
<string name="temperature_plot">Temperature Plot</string>
|
||||
<string name="humidity_plot">Humidity Plot</string>
|
||||
<string name="station_doesnt_measure">The station doesn\'t measure this parameter</string>
|
||||
</resources>
|
Ładowanie…
Reference in New Issue