mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-28 02:27:32 +01:00
Dashboard: Reload preferences on create view
Attempt to mitigate a crash when a device finishes fetching data while the fragment is still being created.
This commit is contained in:
parent
2212b244e6
commit
fa9e111b6b
@ -160,6 +160,8 @@ public class DashboardFragment extends Fragment implements MenuProvider {
|
|||||||
|
|
||||||
if (savedInstanceState != null && savedInstanceState.containsKey("dashboard_data") && dashboardData.isEmpty()) {
|
if (savedInstanceState != null && savedInstanceState.containsKey("dashboard_data") && dashboardData.isEmpty()) {
|
||||||
dashboardData = (DashboardData) savedInstanceState.getSerializable("dashboard_data");
|
dashboardData = (DashboardData) savedInstanceState.getSerializable("dashboard_data");
|
||||||
|
} else if (dashboardData.isEmpty()) {
|
||||||
|
reloadPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
IntentFilter filterLocal = new IntentFilter();
|
IntentFilter filterLocal = new IntentFilter();
|
||||||
@ -226,13 +228,17 @@ public class DashboardFragment extends Fragment implements MenuProvider {
|
|||||||
day.set(Calendar.MINUTE, 59);
|
day.set(Calendar.MINUTE, 59);
|
||||||
day.set(Calendar.SECOND, 59);
|
day.set(Calendar.SECOND, 59);
|
||||||
dashboardData.clear();
|
dashboardData.clear();
|
||||||
|
reloadPreferences();
|
||||||
|
draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reloadPreferences() {
|
||||||
Prefs prefs = GBApplication.getPrefs();
|
Prefs prefs = GBApplication.getPrefs();
|
||||||
dashboardData.showAllDevices = prefs.getBoolean("dashboard_devices_all", true);
|
dashboardData.showAllDevices = prefs.getBoolean("dashboard_devices_all", true);
|
||||||
dashboardData.showDeviceList = prefs.getStringSet("dashboard_devices_multiselect", new HashSet<>());
|
dashboardData.showDeviceList = prefs.getStringSet("dashboard_devices_multiselect", new HashSet<>());
|
||||||
dashboardData.hrIntervalSecs = prefs.getInt("dashboard_widget_today_hr_interval", 1) * 60;
|
dashboardData.hrIntervalSecs = prefs.getInt("dashboard_widget_today_hr_interval", 1) * 60;
|
||||||
dashboardData.timeTo = (int) (day.getTimeInMillis() / 1000);
|
dashboardData.timeTo = (int) (day.getTimeInMillis() / 1000);
|
||||||
dashboardData.timeFrom = DateTimeUtils.shiftDays(dashboardData.timeTo, -1);
|
dashboardData.timeFrom = DateTimeUtils.shiftDays(dashboardData.timeTo, -1);
|
||||||
draw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void draw() {
|
private void draw() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user