MeteoSystem/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/updater/StationDetailsValuesOnActiv...

62 wiersze
1.6 KiB
Java
Czysty Zwykły widok Historia

2021-12-10 10:21:06 +00:00
package cc.pogoda.mobile.meteosystem.activity.updater;
2020-12-16 19:26:53 +00:00
import android.os.Handler;
import org.tinylog.Logger;
2021-12-10 10:21:06 +00:00
import cc.pogoda.mobile.meteosystem.dao.SummaryDao;
import cc.pogoda.mobile.meteosystem.type.StationActivityElements;
import cc.pogoda.mobile.meteosystem.type.WeatherStation;
import cc.pogoda.mobile.meteosystem.type.web.Summary;
2020-12-16 19:26:53 +00:00
/**
* Class used to update the content of StationDetailsSummaryActivity and
* StationDetailsWindRoseActivity
*/
public class StationDetailsValuesOnActivityUpdater implements Runnable {
2020-12-16 19:26:53 +00:00
2020-12-28 22:56:50 +00:00
StationActivityElements elements = null;
2020-12-16 19:26:53 +00:00
Handler handler = null;
SummaryDao dao = null;
Summary station_summary = null;
String station_name;
WeatherStation station;
public StationDetailsValuesOnActivityUpdater(StationActivityElements elems, Handler h, String station_name, WeatherStation station) {
2020-12-16 19:26:53 +00:00
elements = elems;
handler = h;
this.station_name = station_name;
this.station = station;
2020-12-16 19:26:53 +00:00
dao = new SummaryDao();
}
@Override
public void run() {
if (elements == null) {
return;
}
else {
// get the current data from the Web Service
2020-12-16 19:26:53 +00:00
station_summary = dao.getStationSummary(station_name);
Logger.debug("[StationDetailsValuesOnActivityUpdater][run][station_name = " + station_name +"]");
// null check is done inside this call
elements.updateFromSummary(station_summary, station.getAvailableParameters());
2020-12-16 19:26:53 +00:00
handler.postDelayed(this, 90000);
}
}
}