mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-12 17:26:35 +02:00
Fix initial dashboard refresh logic
This commit is contained in:
parent
18e5210103
commit
fed0aebd6a
@ -56,6 +56,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public class DashboardFragment extends Fragment {
|
||||
private boolean isVisible = false;
|
||||
private Calendar day = GregorianCalendar.getInstance();
|
||||
private TextView textViewDate;
|
||||
private TextView arrowLeft;
|
||||
@ -104,10 +105,9 @@ public class DashboardFragment extends Fragment {
|
||||
activeTimeWidget = null;
|
||||
sleepWidget = null;
|
||||
|
||||
// Only load widgets here if the Dashboard is the initial view.
|
||||
// Only load widgets here if the Dashboard is visible.
|
||||
// This prevents a hard crash when replacing the fragment in createWidget() via a FragmentManager.
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
if (prefs.getBoolean("dashboard_as_default_view", true)) refresh();
|
||||
if (isVisible) refresh();
|
||||
|
||||
return dashboardView;
|
||||
}
|
||||
@ -125,6 +125,16 @@ public class DashboardFragment extends Fragment {
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
if (isVisibleToUser) {
|
||||
isVisible = true;
|
||||
} else {
|
||||
isVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
Loading…
Reference in New Issue
Block a user