Fix filter groups

This commit is contained in:
PavelRatushny 2017-07-26 13:50:38 +03:00
parent 57eae66adf
commit fbab53ae7d
2 changed files with 17 additions and 24 deletions

View file

@ -322,29 +322,28 @@ public class SplitSegmentFragment extends OsmAndListFragment {
} }
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) { private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
if (getTrackActivity() == null) {
return null;
}
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
List<GpxDisplayGroup> groups = new ArrayList<>(); List<GpxDisplayGroup> groups = new ArrayList<>();
for (GpxDisplayGroup group : result) { if (getTrackActivity() != null) {
boolean add = hasFilterType(group.getType()); List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) { for (GpxDisplayGroup group : result) {
Iterator<GpxDisplayItem> item = group.getModifiableList().iterator(); boolean add = hasFilterType(group.getType());
while (item.hasNext()) { if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
GpxDisplayItem it2 = item.next(); Iterator<GpxDisplayItem> item = group.getModifiableList().iterator();
if (it2.analysis != null && it2.analysis.totalDistance < 100) { while (item.hasNext()) {
item.remove(); GpxDisplayItem it2 = item.next();
if (it2.analysis != null && it2.analysis.totalDistance < 100) {
item.remove();
}
}
if (group.getModifiableList().isEmpty()) {
add = false;
} }
} }
if (group.getModifiableList().isEmpty()) { if (add) {
add = false; groups.add(group);
} }
}
if (add) {
groups.add(group);
}
}
} }
return groups; return groups;
} }
@ -657,9 +656,6 @@ public class SplitSegmentFragment extends OsmAndListFragment {
} }
if (mSelectedGpxFile != null) { if (mSelectedGpxFile != null) {
List<GpxDisplayGroup> groups = getDisplayGroups(); List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups == null) {
return;
}
mSelectedGpxFile.setDisplayGroups(groups); mSelectedGpxFile.setDisplayGroups(groups);
} }
updateContent(); updateContent();

View file

@ -1542,9 +1542,6 @@ public class TrackSegmentFragment extends OsmAndListFragment {
} }
if (mSelectedGpxFile != null) { if (mSelectedGpxFile != null) {
List<GpxDisplayGroup> groups = getDisplayGroups(); List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups == null) {
return;
}
mSelectedGpxFile.setDisplayGroups(groups); mSelectedGpxFile.setDisplayGroups(groups);
} }
if (mFragment.isVisible()) { if (mFragment.isVisible()) {