Interval statistics: listen preferred units change (metric/imperial) and recreate intervals.

This commit is contained in:
Román
2020-08-12 16:20:07 +02:00
committed by Román Martínez
parent cbc803d038
commit a6c3cf1c28
4 changed files with 33 additions and 8 deletions
@@ -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() {