kopia lustrzana https://github.com/SP8EBC/MeteoSystem
downloading available parameters only when they are required instead of all at once during startup
rodzic
d458fbba2e
commit
ec1adccea1
|
@ -145,7 +145,7 @@ public class Main extends Application {
|
|||
// recreate list of favorites
|
||||
recreateListOfFavs();
|
||||
|
||||
favsSummaryUpdater = new FavouritesStationSummaryUpdaterThread(hashmapFavStationSystemNameToSummary);
|
||||
favsSummaryUpdater = new FavouritesStationSummaryUpdaterThread(hashmapFavStationSystemNameToSummary, hashmapAllStationSystemNameToAvailParameters);
|
||||
|
||||
favsSummaryUpdater.start(100);
|
||||
|
||||
|
@ -271,7 +271,6 @@ public class Main extends Application {
|
|||
public void allStationsEventHandler(@NonNull AllStationsReceivedEvent event) {
|
||||
Logger.info("[event = " + event.toString() +"]");
|
||||
this.listOfAllStations = event.getStations();
|
||||
this.hashmapAllStationSystemNameToAvailParameters = event.getAvailableParameters();
|
||||
recreateListOfFavs();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cc.pogoda.mobile.meteosystem.activity.updater.thread;
|
||||
|
||||
import static cc.pogoda.mobile.meteosystem.config.ConstAppConfiguration.REUPDATE_VALUES_ON_ACTIVITY_ON_FAIL;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.telephony.SubscriptionManager;
|
||||
|
||||
|
@ -15,7 +17,10 @@ import java.util.concurrent.ScheduledFuture;
|
|||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cc.pogoda.mobile.meteosystem.dao.AvailableParametersDao;
|
||||
import cc.pogoda.mobile.meteosystem.dao.SummaryDao;
|
||||
import cc.pogoda.mobile.meteosystem.type.AvailableParameters;
|
||||
import cc.pogoda.mobile.meteosystem.type.web.AvailableParametersWeb;
|
||||
import cc.pogoda.mobile.meteosystem.type.web.Summary;
|
||||
|
||||
/**
|
||||
|
@ -26,8 +31,12 @@ public class FavouritesStationSummaryUpdaterThread implements Runnable {
|
|||
|
||||
private HashMap<String, Summary> map;
|
||||
|
||||
private HashMap<String, AvailableParameters> availableParametersHashMap;
|
||||
|
||||
private SummaryDao summaryDao;
|
||||
|
||||
private AvailableParametersDao availableParametersDao;
|
||||
|
||||
private ScheduledExecutorService executor;
|
||||
|
||||
private ScheduledFuture scheduledTask;
|
||||
|
@ -39,9 +48,12 @@ public class FavouritesStationSummaryUpdaterThread implements Runnable {
|
|||
*/
|
||||
private boolean forceUpdate = false;
|
||||
|
||||
public FavouritesStationSummaryUpdaterThread(HashMap<String, Summary> _out_map) {
|
||||
public FavouritesStationSummaryUpdaterThread(HashMap<String, Summary> _out_map, HashMap<String, AvailableParameters> _avail_params_map) {
|
||||
map = _out_map;
|
||||
availableParametersHashMap = _avail_params_map;
|
||||
|
||||
summaryDao = new SummaryDao();
|
||||
availableParametersDao = new AvailableParametersDao();
|
||||
|
||||
executor = Executors.newScheduledThreadPool(5);
|
||||
}
|
||||
|
@ -75,6 +87,12 @@ public class FavouritesStationSummaryUpdaterThread implements Runnable {
|
|||
// put the summary back into the map
|
||||
map.put(station_name, summary);
|
||||
}
|
||||
|
||||
AvailableParameters parameters = AvailableParameters.fromWebData(availableParametersDao.getAvaliableParamsByStationName(station_name));
|
||||
|
||||
if (parameters != null) {
|
||||
availableParametersHashMap.put(station_name, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,7 +104,7 @@ public class FavouritesStationSummaryUpdaterThread implements Runnable {
|
|||
Logger.info("[no station to update]");
|
||||
|
||||
stop();
|
||||
start(5000);
|
||||
start(REUPDATE_VALUES_ON_ACTIVITY_ON_FAIL);
|
||||
}
|
||||
|
||||
if (forceUpdate) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cc.pogoda.mobile.meteosystem.activity.updater.thread;
|
||||
|
||||
import static cc.pogoda.mobile.meteosystem.config.ConstAppConfiguration.REUPDATE_VALUES_ON_ACTIVITY_ON_FAIL;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.tinylog.Logger;
|
||||
|
@ -60,7 +62,7 @@ public class StationSummaryUpdaterThread implements Runnable {
|
|||
Logger.info("[no station to update]");
|
||||
|
||||
stop();
|
||||
start(5000);
|
||||
start(REUPDATE_VALUES_ON_ACTIVITY_ON_FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,21 +30,11 @@ public class GetAllStationsService extends JobIntentService {
|
|||
protected void onHandleWork(@NonNull Intent intent) {
|
||||
EventBus.getDefault().post(new StartStationsRefreshEvent());
|
||||
|
||||
AvailableParametersDao availableParametersDao = new AvailableParametersDao();
|
||||
|
||||
// download all stations
|
||||
List<WeatherStation> allStations = new AllStationsDao().getAllStations();
|
||||
if (allStations != null){
|
||||
HashMap<String, AvailableParameters> availableParametersHashMap = new HashMap<>();
|
||||
|
||||
// download available parameters for all stations
|
||||
for (WeatherStation w : allStations) {
|
||||
String systemName = w.getSystemName();
|
||||
|
||||
availableParametersHashMap.put(systemName, AvailableParameters.fromWebData(availableParametersDao.getAvaliableParamsByStationName(systemName)));
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(new AllStationsReceivedEvent(allStations, availableParametersHashMap));
|
||||
EventBus.getDefault().post(new AllStationsReceivedEvent(allStations));
|
||||
Logger.debug("onHandleWork done. allStations size:" + allStations.size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,10 @@ import java.util.List;
|
|||
public class AllStationsReceivedEvent {
|
||||
List<WeatherStation> stations;
|
||||
|
||||
HashMap<String, AvailableParameters> availableParameters;
|
||||
|
||||
public AllStationsReceivedEvent(@NonNull List<WeatherStation> stations, @NonNull HashMap<String, AvailableParameters> availableParametersHashMap) {
|
||||
public AllStationsReceivedEvent(@NonNull List<WeatherStation> stations) {
|
||||
this.stations = stations;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public HashMap<String, AvailableParameters> getAvailableParameters() {
|
||||
return availableParameters;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public List<WeatherStation> getStations(){
|
||||
return this.stations;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
android:id="@+id/textViewTemperatureValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="---"
|
||||
android:text="@string/please_wait"
|
||||
android:textAlignment="center"
|
||||
android:textSize="50sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -187,5 +187,9 @@
|
|||
<string name="export_decimation">Decimace eskportovaných údajov</string>
|
||||
<string name="export_decimation_minutes">Minimální krok v minutách</string>
|
||||
<string name="www_link">URL pro více informací</string>
|
||||
<string name="please_wait">Please Wait</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -187,5 +187,9 @@
|
|||
<string name="export_decimation">Decimace eskportovaných údajov</string>
|
||||
<string name="export_decimation_minutes">Minimální krok v minutách</string>
|
||||
<string name="www_link">URL pro více informací</string>
|
||||
<string name="please_wait">Please Wait</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -116,6 +116,10 @@
|
|||
<string name="export_decimation">Dezimierung exportierten Dateien </string>
|
||||
<string name="export_decimation_minutes">Minimaler Schritt in Minuten </string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Please Wait</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
|
|
@ -116,6 +116,10 @@
|
|||
<string name="export_decimation">Dezimierung exportierten Dateien </string>
|
||||
<string name="export_decimation_minutes">Minimaler Schritt in Minuten </string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Please Wait</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
|
|
@ -116,6 +116,10 @@
|
|||
<string name="export_decimation">Dezimierung exportierten Dateien </string>
|
||||
<string name="export_decimation_minutes">Minimaler Schritt in Minuten </string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Please Wait</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
|
|
@ -115,5 +115,8 @@
|
|||
<string name="export_decimation_minutes">Minimum time resolution</string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="please_wait">Please Wait</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
|
||||
</resources>
|
|
@ -114,4 +114,8 @@
|
|||
<string name="export_decimation">Export data decimation</string>
|
||||
<string name="export_decimation_minutes">Minimum time resolution</string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Please Wait</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
||||
|
|
|
@ -114,4 +114,8 @@
|
|||
<string name="export_decimation">Export data decimation</string>
|
||||
<string name="export_decimation_minutes">Minimum time resolution</string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Please Wait</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
||||
|
|
|
@ -117,4 +117,5 @@
|
|||
<string name="refreshing_station_list">Odświeżanie listy stacji</string>
|
||||
<string name="all_stations_empty_list1">Brak stacji na liście.</string>
|
||||
<string name="all_station_empty_list2">Proszę poczekać lub pociągnąć w dół aby odświeżyć.</string>
|
||||
<string name="please_wait">Proszę czekać</string>
|
||||
</resources>
|
|
@ -114,4 +114,8 @@
|
|||
<string name="export_decimation">Decymacja eskportowanych danych</string>
|
||||
<string name="export_decimation_minutes">Minimalny krok w minutach</string>
|
||||
<string name="www_link">Więcej informacji</string>
|
||||
<string name="please_wait">Proszę czekać</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
|
@ -114,4 +114,8 @@
|
|||
<string name="export_decimation">Децимация экспортируемых данных</string>
|
||||
<string name="export_decimation_minutes">Минимальный шаг в минутах</string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Proszę czekać</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
|
@ -114,4 +114,8 @@
|
|||
<string name="export_decimation">Децимация экспортируемых данных</string>
|
||||
<string name="export_decimation_minutes">Минимальный шаг в минутах</string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Proszę czekać</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
|
@ -114,4 +114,8 @@
|
|||
<string name="export_decimation">Децимация экспортируемых данных</string>
|
||||
<string name="export_decimation_minutes">Минимальный шаг в минутах</string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Proszę czekać</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
|
@ -114,4 +114,7 @@
|
|||
<string name="export_decimation">Децимація експортованих даних</string>
|
||||
<string name="export_decimation_minutes">Мінімальний крок у хвилинах</string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Proszę czekać</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
</resources>
|
|
@ -114,4 +114,8 @@
|
|||
<string name="export_decimation">Децимація експортованих даних</string>
|
||||
<string name="export_decimation_minutes">Мінімальний крок у хвилинах</string>
|
||||
<string name="www_link">URL to more information</string>
|
||||
<string name="please_wait">Proszę czekać</string>
|
||||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
</resources>
|
|
@ -147,4 +147,5 @@
|
|||
<string name="refreshing_station_list">Refreshing station list</string>
|
||||
<string name="all_stations_empty_list1">There are no stations on this list.</string>
|
||||
<string name="all_station_empty_list2">Please wait or pull down to refresh list.</string>
|
||||
<string name="please_wait">Please Wait</string>
|
||||
</resources>
|
Ładowanie…
Reference in New Issue