kopia lustrzana https://github.com/SP8EBC/MeteoSystem
new values on wind rose
rodzic
a8a7053d19
commit
28c89acfc3
|
@ -4,12 +4,9 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import cc.pogoda.mobile.pogodacc.R;
|
||||
import cc.pogoda.mobile.pogodacc.activity.updater.StationDetailsSummaryValUpdater;
|
||||
import cc.pogoda.mobile.pogodacc.activity.updater.StationDetailsValuesUpdater;
|
||||
import cc.pogoda.mobile.pogodacc.dao.SummaryDao;
|
||||
import cc.pogoda.mobile.pogodacc.type.StationSummaryActElements;
|
||||
import cc.pogoda.mobile.pogodacc.type.WeatherStation;
|
||||
|
@ -21,7 +18,7 @@ public class StationDetailsSummaryActivity extends AppCompatActivity {
|
|||
|
||||
WeatherStation station = null;
|
||||
|
||||
StationDetailsSummaryValUpdater updater = null;
|
||||
StationDetailsValuesUpdater updater = null;
|
||||
|
||||
Handler handler = null;
|
||||
|
||||
|
@ -52,7 +49,7 @@ public class StationDetailsSummaryActivity extends AppCompatActivity {
|
|||
elems.updateFromSummary(summary);
|
||||
|
||||
handler = new Handler();
|
||||
updater = new StationDetailsSummaryValUpdater(elems, handler, station.getSystemName());
|
||||
updater = new StationDetailsValuesUpdater(elems, handler, station.getSystemName());
|
||||
|
||||
if (handler != null && updater != null) {
|
||||
handler.post(updater);
|
||||
|
|
|
@ -3,14 +3,73 @@ package cc.pogoda.mobile.pogodacc.activity;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import cc.pogoda.mobile.pogodacc.R;
|
||||
import cc.pogoda.mobile.pogodacc.activity.updater.StationDetailsValuesUpdater;
|
||||
import cc.pogoda.mobile.pogodacc.dao.SummaryDao;
|
||||
import cc.pogoda.mobile.pogodacc.type.StationWindRoseActElements;
|
||||
import cc.pogoda.mobile.pogodacc.type.WeatherStation;
|
||||
import cc.pogoda.mobile.pogodacc.type.web.Summary;
|
||||
|
||||
public class StationDetailsWindRoseActivity extends AppCompatActivity {
|
||||
|
||||
WeatherStation station;
|
||||
|
||||
Summary summary;
|
||||
|
||||
StationDetailsValuesUpdater updater = null;
|
||||
|
||||
Handler handler = null;
|
||||
|
||||
StationWindRoseActElements elements;
|
||||
|
||||
public StationDetailsWindRoseActivity() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_station_details_wind_rose);
|
||||
|
||||
station = (WeatherStation) getIntent().getSerializableExtra("station");
|
||||
|
||||
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.setActivity(this);
|
||||
|
||||
// create the hanlder which will update the screen in background
|
||||
handler = new Handler();
|
||||
|
||||
SummaryDao summary_dao = new SummaryDao();
|
||||
|
||||
// get the set of current values to preconfigure all elements on this activity
|
||||
summary = summary_dao.getStationSummary(station.getSystemName());
|
||||
|
||||
// update parameters (like turn the wind direction arrow)
|
||||
elements.updateFromSummary(summary);
|
||||
|
||||
handler = new Handler();
|
||||
updater = new StationDetailsValuesUpdater(elements, handler, station.getSystemName());
|
||||
|
||||
if (handler != null && updater != null) {
|
||||
handler.post(updater);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
|
||||
if (handler != null && updater != null) {
|
||||
handler.removeCallbacks(updater);
|
||||
}
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
}
|
|
@ -3,12 +3,13 @@ package cc.pogoda.mobile.pogodacc.activity.updater;
|
|||
import android.os.Handler;
|
||||
|
||||
import cc.pogoda.mobile.pogodacc.dao.SummaryDao;
|
||||
import cc.pogoda.mobile.pogodacc.type.StationActivityElements;
|
||||
import cc.pogoda.mobile.pogodacc.type.StationSummaryActElements;
|
||||
import cc.pogoda.mobile.pogodacc.type.web.Summary;
|
||||
|
||||
public class StationDetailsSummaryValUpdater implements Runnable {
|
||||
public class StationDetailsValuesUpdater implements Runnable {
|
||||
|
||||
StationSummaryActElements elements = null;
|
||||
StationActivityElements elements = null;
|
||||
|
||||
Handler handler = null;
|
||||
|
||||
|
@ -18,7 +19,7 @@ public class StationDetailsSummaryValUpdater implements Runnable {
|
|||
|
||||
String station_name;
|
||||
|
||||
public StationDetailsSummaryValUpdater(StationSummaryActElements elems, Handler h, String s) {
|
||||
public StationDetailsValuesUpdater(StationActivityElements elems, Handler h, String s) {
|
||||
elements = elems;
|
||||
handler = h;
|
||||
station_name = s;
|
|
@ -0,0 +1,16 @@
|
|||
package cc.pogoda.mobile.pogodacc.type;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import cc.pogoda.mobile.pogodacc.type.web.Summary;
|
||||
|
||||
/**
|
||||
* This is an interface which is used to implement classes used for updating the activity content
|
||||
* asynchronously (in the background)
|
||||
*/
|
||||
public interface StationActivityElements {
|
||||
|
||||
public void updateFromSummary(Summary s);
|
||||
|
||||
public void setActivity(Activity act);
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package cc.pogoda.mobile.pogodacc.type;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cc.pogoda.mobile.pogodacc.type.web.Summary;
|
||||
|
||||
public class StationSummaryActElements {
|
||||
public class StationSummaryActElements implements StationActivityElements {
|
||||
|
||||
public TextView title = null;
|
||||
public TextView wind_speed_val = null;
|
||||
|
@ -75,4 +76,9 @@ public class StationSummaryActElements {
|
|||
humidity_val.setText(String.format("%d %", s.humidity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivity(Activity act) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package cc.pogoda.mobile.pogodacc.type;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cc.pogoda.mobile.pogodacc.R;
|
||||
import cc.pogoda.mobile.pogodacc.type.web.Summary;
|
||||
|
||||
public class StationWindRoseActElements implements StationActivityElements {
|
||||
|
||||
public ImageView windArrow;
|
||||
|
||||
public TextView windSpeed;
|
||||
|
||||
public TextView windGusts;
|
||||
|
||||
public TextView windDirection;
|
||||
|
||||
public TextView temperature;
|
||||
|
||||
public TextView pressure;
|
||||
|
||||
Activity activity;
|
||||
|
||||
public StationWindRoseActElements() {
|
||||
windArrow = null;
|
||||
windGusts = null;
|
||||
windSpeed = null;
|
||||
temperature = null;
|
||||
pressure = null;
|
||||
activity = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFromSummary(Summary s) {
|
||||
|
||||
if (activity == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (windArrow != null) {
|
||||
windArrow.setRotation(s.direction - 225.0f);
|
||||
}
|
||||
|
||||
if (windSpeed != null) {
|
||||
windSpeed.setText(activity.getResources().getString(R.string.mean_value) + '\n' + s.average_speed + "m/s");
|
||||
}
|
||||
|
||||
if (windGusts != null) {
|
||||
windGusts.setText(activity.getResources().getString(R.string.wind_gust_short) + '\n' + s.gusts + "m/s");
|
||||
}
|
||||
|
||||
if (windDirection != null) {
|
||||
windDirection.setText(activity.getResources().getString(R.string.wind_direction_short) + '\n' + s.direction + activity.getResources().getString(R.string.degrees_sign));
|
||||
}
|
||||
|
||||
if (temperature != null) {
|
||||
temperature.setText(activity.getResources().getString(R.string.temperature_short) + '\n' + String.format("%.1f", s.avg_temperature) + "°C");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivity(Activity act) {
|
||||
activity = act;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="49.636dp"
|
||||
android:height="49.636dp"
|
||||
android:viewportWidth="49.636"
|
||||
android:viewportHeight="49.636">
|
||||
<path
|
||||
android:pathData="M23.001,27.245l-23.001,-3.855l49.636,-22.78l-24,48.416z"
|
||||
android:fillColor="#1081E0"/>
|
||||
</vector>
|
|
@ -32,6 +32,74 @@
|
|||
app:layout_constraintTop_toTopOf="@id/guidelineRoseNUp"
|
||||
app:srcCompat="@drawable/ic_brosen_windrose" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewWindRoseArrow"
|
||||
android:layout_width="205dp"
|
||||
android:layout_height="206dp"
|
||||
android:alpha="0.8"
|
||||
android:rotation="-45"
|
||||
app:layout_constraintBottom_toBottomOf="@id/guidelineRoseSDown"
|
||||
app:layout_constraintEnd_toEndOf="@id/guidelineWindRoseVertivalRight"
|
||||
app:layout_constraintStart_toStartOf="@id/guidelineWindRoseVerticalLeft"
|
||||
app:layout_constraintTop_toTopOf="@id/guidelineRoseNUp"
|
||||
app:srcCompat="@drawable/ic_navigation" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewWindRoseWindSpeed"
|
||||
android:layout_width="152dp"
|
||||
android:layout_height="69dp"
|
||||
android:text="Średnia"
|
||||
android:textAlignment="center"
|
||||
android:textSize="28sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/guidelineRoseSDown"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/guidelineRoseNUp"
|
||||
app:layout_constraintVertical_bias="0.096" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewWindRoseWindDirection"
|
||||
android:layout_width="152dp"
|
||||
android:layout_height="69dp"
|
||||
android:text="Kierunek"
|
||||
android:textAlignment="center"
|
||||
android:textSize="28sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/guidelineRoseSDown"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/guidelineRoseNUp"
|
||||
app:layout_constraintVertical_bias="0.896" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewWindRoseTemperatura"
|
||||
android:layout_width="152dp"
|
||||
android:layout_height="69dp"
|
||||
android:text="Temp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="28sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/guidelineRoseSDown"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/guidelineRoseNUp"
|
||||
app:layout_constraintVertical_bias="0.896" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewWindRoseWindGusts"
|
||||
android:layout_width="152dp"
|
||||
android:layout_height="70dp"
|
||||
android:text="Poryw"
|
||||
android:textAlignment="center"
|
||||
android:textSize="28sp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/guidelineRoseSDown"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/guidelineRoseNUp"
|
||||
app:layout_constraintVertical_bias="0.095" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewSouth"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -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 Value</string>
|
||||
<string name="mean_value">Mean</string>
|
||||
<string name="max_value">Maximum Value</string>
|
||||
<string name="show_previous">Show previous</string>
|
||||
<string name="hours">Hours</string>
|
||||
|
@ -41,4 +41,10 @@
|
|||
<string name="mean_value_short">Avg:</string>
|
||||
<string name="max_value_short">Max:</string>
|
||||
<string name="add_fav">Add to favourities</string>
|
||||
<string name="wind_gust_short">Gust</string>
|
||||
<string name="last_hour">Last Hour</string>
|
||||
<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>
|
||||
</resources>
|
|
@ -41,4 +41,10 @@
|
|||
<string name="mean_value_short">-</string>
|
||||
<string name="max_value_short">-</string>
|
||||
<string name="add_fav">-</string>
|
||||
<string name="wind_gust_short">-</string>
|
||||
<string name="last_hour">-</string>
|
||||
<string name="wind_direction_short">-</string>
|
||||
<string name="temperature_short">-</string>
|
||||
<string name="degress">-</string>
|
||||
<string name="max_1h_gust">-</string>
|
||||
</resources>
|
|
@ -41,5 +41,11 @@
|
|||
<string name="mean_value_short">-</string>
|
||||
<string name="max_value_short">-</string>
|
||||
<string name="add_fav">-</string>
|
||||
<string name="wind_gust_short">-</string>
|
||||
<string name="last_hour">-</string>
|
||||
<string name="wind_direction_short">-</string>
|
||||
<string name="temperature_short">-</string>
|
||||
<string name="degress">-</string>
|
||||
<string name="max_1h_gust">-</string>
|
||||
|
||||
</resources>
|
|
@ -24,7 +24,7 @@
|
|||
<string name="archive_data">Dane Archiwalne</string>
|
||||
<string name="export_from">Exportuj do</string>
|
||||
<string name="time_scale">Skala czasu</string>
|
||||
<string name="mean_value">Wartość średnia</string>
|
||||
<string name="mean_value">Średnia</string>
|
||||
<string name="max_value">Wartość maksymalna</string>
|
||||
<string name="show_previous">Pokaż ostatnie</string>
|
||||
<string name="hours">Godziny</string>
|
||||
|
@ -38,7 +38,13 @@
|
|||
<string name="apply">Zastosuj</string>
|
||||
<string name="cancel">Anuluj</string>
|
||||
<string name="wind_rose">Róża Wiatrów</string>
|
||||
<string name="mean_value_short">Śr:</string>
|
||||
<string name="max_value_short">Max:</string>
|
||||
<string name="mean_value_short">Śr</string>
|
||||
<string name="max_value_short">Max</string>
|
||||
<string name="add_fav">Dodaj do ulubionych</string>
|
||||
<string name="wind_gust_short">Poryw</string>
|
||||
<string name="last_hour">Ostatnia Godzina</string>
|
||||
<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>
|
||||
</resources>
|
|
@ -24,7 +24,7 @@
|
|||
<string name="archive_data">Dane Archiwalne</string>
|
||||
<string name="export_from">Eksportuj od</string>
|
||||
<string name="time_scale">Skala czasu</string>
|
||||
<string name="mean_value">Wartość średnia</string>
|
||||
<string name="mean_value">Średnia</string>
|
||||
<string name="max_value">Wartość masymalna</string>
|
||||
<string name="show_previous">Pokaż ostatnie</string>
|
||||
<string name="hours">Godziny</string>
|
||||
|
@ -38,7 +38,13 @@
|
|||
<string name="apply">Zastosuj</string>
|
||||
<string name="cancel">Anuluj</string>
|
||||
<string name="wind_rose">Róża Wiatrów</string>
|
||||
<string name="mean_value_short">Śr:</string>
|
||||
<string name="max_value_short">Max:</string>
|
||||
<string name="mean_value_short">Śr</string>
|
||||
<string name="max_value_short">Max</string>
|
||||
<string name="add_fav">Ddoaj do ulubionych</string>
|
||||
<string name="wind_gust_short">Poryw</string>
|
||||
<string name="last_hour">Ostatnia Godzina</string>
|
||||
<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>
|
||||
</resources>
|
|
@ -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 Value</string>
|
||||
<string name="mean_value">Mean</string>
|
||||
<string name="max_value">Maximum Value</string>
|
||||
<string name="show_previous">Show previous</string>
|
||||
<string name="hours">Hours</string>
|
||||
|
@ -44,4 +44,11 @@
|
|||
<string name="south" translatable="false">S</string>
|
||||
<string name="east" translatable="false">E</string>
|
||||
<string name="west" translatable="false">W</string>
|
||||
<string name="wind_gust_short">Gust</string>
|
||||
<string name="last_hour">Last Hour</string>
|
||||
<string name="wind_direction_short">Direction</string>
|
||||
<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>
|
||||
</resources>
|
Ładowanie…
Reference in New Issue