Interval Stats: fixed NPE introduced in 25ef0ecad1.

Includes some refactoring.
This commit is contained in:
Dennis Guse
2020-09-02 23:12:52 +02:00
parent 951671b2f3
commit 24e6cdec62
7 changed files with 14 additions and 26 deletions
@@ -60,7 +60,7 @@ public class IntervalsRecordedFragment extends Fragment implements IntervalListV
viewModel = new ViewModelProvider(this).get(IntervalStatisticsModel.class);
updateIntervals(null);
intervalChanged(null);
}
@Override
@@ -77,7 +77,8 @@ public class IntervalsRecordedFragment extends Fragment implements IntervalListV
*
* @param interval intervals will split in this interval if not null. If it's null then view model will use the default one.
*/
private void updateIntervals(@Nullable IntervalStatisticsModel.IntervalOption interval) {
@Override
public void intervalChanged(IntervalStatisticsModel.IntervalOption interval) {
if (viewModel == null || intervalListView == null) {
return;
}
@@ -95,9 +96,4 @@ public class IntervalsRecordedFragment extends Fragment implements IntervalListV
}
});
}
@Override
public void intervalChanged(IntervalStatisticsModel.IntervalOption interval) {
updateIntervals(interval);
}
}
@@ -106,7 +106,8 @@ public class IntervalsRecordingFragment extends Fragment implements IntervalList
*
* @param interval intervals will split in this interval if not null. If it's null then view model will use the default one.
*/
private void updateIntervals(@Nullable IntervalStatisticsModel.IntervalOption interval) {
@Override
public void intervalChanged(IntervalStatisticsModel.IntervalOption interval) {
if (viewModel == null || intervalListView == null) {
return;
}
@@ -126,11 +127,7 @@ public class IntervalsRecordingFragment extends Fragment implements IntervalList
}
private void updateIntervals() {
updateIntervals(null);
intervalChanged(null);
}
@Override
public void intervalChanged(IntervalStatisticsModel.IntervalOption interval) {
updateIntervals(interval);
}
}
@@ -109,8 +109,6 @@ public class StatisticsRecordedFragment extends Fragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ViewGroup rootView = view.findViewById(R.id.root_view);
totalTimeValueView = view.findViewById(R.id.stats_total_time_value);
distanceValue = view.findViewById(R.id.stats_distance_value);
@@ -48,8 +48,6 @@ public class StatisticsRecordingFragment extends Fragment implements TrackDataLi
private static final String TAG = StatisticsRecordingFragment.class.getSimpleName();
private static final String TRACK_ID_KEY = "trackId";
private static final long UI_UPDATE_INTERVAL = UnitConversions.ONE_SECOND_MS;
private TrackDataHub trackDataHub;