forked from upstream-mirrors/OpenTracks
Interval statistics: listen preferred units change (metric/imperial) and recreate intervals.
This commit is contained in:
@@ -63,6 +63,9 @@ public class StatisticsRecordedFragment extends Fragment implements IntervalList
|
||||
|
||||
private final SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener = (preferences, key) -> {
|
||||
if (PreferencesUtils.isKey(getContext(), R.string.stats_units_key, key) || PreferencesUtils.isKey(getContext(), R.string.stats_rate_key, key)) {
|
||||
if (viewModel != null) {
|
||||
viewModel.invalidate();
|
||||
}
|
||||
if (isResumed()) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (isResumed()) {
|
||||
@@ -187,16 +190,12 @@ public class StatisticsRecordedFragment extends Fragment implements IntervalList
|
||||
loadStatistics();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
PreferencesUtils.unregister(getContext(), sharedPreferenceChangeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
PreferencesUtils.unregister(getContext(), sharedPreferenceChangeListener);
|
||||
|
||||
totalTimeValueView = null;
|
||||
|
||||
distanceValue = null;
|
||||
@@ -218,6 +217,10 @@ public class StatisticsRecordedFragment extends Fragment implements IntervalList
|
||||
speedMovingLabel = null;
|
||||
speedMovingValue = null;
|
||||
speedMovingUnit = null;
|
||||
|
||||
intervalListView.destroy();
|
||||
intervalListView = null;
|
||||
viewModel = null;
|
||||
}
|
||||
|
||||
public void loadStatistics() {
|
||||
|
||||
Reference in New Issue
Block a user