forked from upstream-mirrors/OpenTracks
Cleanup: rename category to activityType.
This commit is contained in:
+12
-12
@@ -26,7 +26,7 @@ public class AggregatedStatistics {
|
||||
dataList.addAll(dataMap.values());
|
||||
Collections.sort(dataList, (o1, o2) -> {
|
||||
if (o1.getCountTracks() == o2.getCountTracks()) {
|
||||
return o1.getCategory().compareTo(o2.getCategory());
|
||||
return o1.getActivityType().compareTo(o2.getActivityType());
|
||||
}
|
||||
return (o1.getCountTracks() < o2.getCountTracks() ? 1 : -1);
|
||||
});
|
||||
@@ -34,11 +34,11 @@ public class AggregatedStatistics {
|
||||
|
||||
@VisibleForTesting
|
||||
public void aggregate(@NonNull Track track) {
|
||||
String category = track.getCategory();
|
||||
if (dataMap.containsKey(category)) {
|
||||
dataMap.get(category).add(track.getTrackStatistics());
|
||||
String activityType = track.getActivityType();
|
||||
if (dataMap.containsKey(activityType)) {
|
||||
dataMap.get(activityType).add(track.getTrackStatistics());
|
||||
} else {
|
||||
dataMap.put(category, new AggregatedStatistic(category, track.getTrackStatistics()));
|
||||
dataMap.put(activityType, new AggregatedStatistic(activityType, track.getTrackStatistics()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ public class AggregatedStatistics {
|
||||
return dataMap.size();
|
||||
}
|
||||
|
||||
public AggregatedStatistic get(String category) {
|
||||
return dataMap.get(category);
|
||||
public AggregatedStatistic get(String activityType) {
|
||||
return dataMap.get(activityType);
|
||||
}
|
||||
|
||||
public AggregatedStatistic getItem(int position) {
|
||||
@@ -55,17 +55,17 @@ public class AggregatedStatistics {
|
||||
}
|
||||
|
||||
public static class AggregatedStatistic {
|
||||
private final String category;
|
||||
private final String activityType;
|
||||
private final TrackStatistics trackStatistics;
|
||||
private int countTracks = 1;
|
||||
|
||||
public AggregatedStatistic(String category, TrackStatistics trackStatistics) {
|
||||
this.category = category;
|
||||
public AggregatedStatistic(String activityType, TrackStatistics trackStatistics) {
|
||||
this.activityType = activityType;
|
||||
this.trackStatistics = trackStatistics;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
public String getActivityType() {
|
||||
return activityType;
|
||||
}
|
||||
|
||||
public TrackStatistics getTrackStatistics() {
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ public class AggregatedStatisticsActivity extends AbstractActivity implements Fi
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == R.id.aggregated_statistics_filter) {
|
||||
ArrayList<FilterDialogFragment.FilterItem> filterItems = new ArrayList<>();
|
||||
adapter.getCategories().stream().forEach(category -> filterItems.add(new FilterDialogFragment.FilterItem(category, category, true)));
|
||||
adapter.getCategories().stream().forEach(activityType -> filterItems.add(new FilterDialogFragment.FilterItem(activityType, activityType, true)));
|
||||
FilterDialogFragment.showDialog(getSupportFragmentManager(), filterItems);
|
||||
return true;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class AggregatedStatisticsActivity extends AbstractActivity implements Fi
|
||||
public void onFilterDone(ArrayList<FilterDialogFragment.FilterItem> filterItems, LocalDateTime from, LocalDateTime to) {
|
||||
setMenuVisibility(true);
|
||||
selection.addDateRange(from.atZone(ZoneId.systemDefault()).toInstant(), to.atZone(ZoneId.systemDefault()).toInstant());
|
||||
filterItems.stream().filter(fi -> fi.isChecked).forEach(fi -> selection.addCategory(fi.value));
|
||||
filterItems.stream().filter(fi -> fi.isChecked).forEach(fi -> selection.addActivityType(fi.value));
|
||||
viewModel.updateSelection(selection);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -62,7 +62,7 @@ public class AggregatedStatisticsAdapter extends BaseAdapter {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
if (TrackIconUtils.isSpeedIcon(context.getResources(), aggregatedStatistic.getCategory())) {
|
||||
if (TrackIconUtils.isSpeedIcon(context.getResources(), aggregatedStatistic.getActivityType())) {
|
||||
viewHolder.setSpeed(aggregatedStatistic);
|
||||
} else {
|
||||
viewHolder.setPace(aggregatedStatistic);
|
||||
@@ -80,7 +80,7 @@ public class AggregatedStatisticsAdapter extends BaseAdapter {
|
||||
public List<String> getCategories() {
|
||||
List<String> categories = new ArrayList<>();
|
||||
for (int i = 0; i < aggregatedStatistics.getCount(); i++) {
|
||||
categories.add(aggregatedStatistics.getItem(i).getCategory());
|
||||
categories.add(aggregatedStatistics.getItem(i).getActivityType());
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
@@ -159,13 +159,13 @@ public class AggregatedStatisticsAdapter extends BaseAdapter {
|
||||
|
||||
//TODO Check preference handling.
|
||||
private void setCommonValues(AggregatedStatistics.AggregatedStatistic aggregatedStatistic) {
|
||||
String category = aggregatedStatistic.getCategory();
|
||||
String activityType = aggregatedStatistic.getActivityType();
|
||||
|
||||
reportSpeed = PreferencesUtils.isReportSpeed(category);
|
||||
reportSpeed = PreferencesUtils.isReportSpeed(activityType);
|
||||
unitSystem = PreferencesUtils.getUnitSystem();
|
||||
|
||||
sportIcon.setImageResource(getIcon(aggregatedStatistic));
|
||||
typeLabel.setText(category);
|
||||
typeLabel.setText(activityType);
|
||||
numTracks.setText(StringUtils.valueInParentheses(String.valueOf(aggregatedStatistic.getCountTracks())));
|
||||
|
||||
Pair<String, String> parts = DistanceFormatter.Builder()
|
||||
@@ -178,7 +178,7 @@ public class AggregatedStatisticsAdapter extends BaseAdapter {
|
||||
}
|
||||
|
||||
private int getIcon(AggregatedStatistics.AggregatedStatistic aggregatedStatistic) {
|
||||
String iconValue = TrackIconUtils.getIconValue(context, aggregatedStatistic.getCategory());
|
||||
String iconValue = TrackIconUtils.getIconValue(context, aggregatedStatistic.getActivityType());
|
||||
return TrackIconUtils.getIconDrawable(iconValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class IntervalsFragment extends Fragment {
|
||||
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(getContext());
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
if (track != null) {
|
||||
isReportSpeed = PreferencesUtils.isReportSpeed(track.getCategory());
|
||||
isReportSpeed = PreferencesUtils.isReportSpeed(track.getActivityType());
|
||||
}
|
||||
|
||||
viewModel = new ViewModelProvider(getActivity()).get(IntervalStatisticsModel.class);
|
||||
|
||||
Reference in New Issue
Block a user