This commit is contained in:
PavelRatushny 2017-07-11 17:42:41 +03:00
parent 5651e9310c
commit e3f4917faf
3 changed files with 58 additions and 27 deletions

View file

@ -373,6 +373,7 @@ public class GPXUtilities {
} }
long time = point.time; long time = point.time;
if (time != 0) { if (time != 0) {
if (s.metricEnd == 0) {
if (s.segment.generalSegment) { if (s.segment.generalSegment) {
if (point.firstPoint) { if (point.firstPoint) {
startTimeOfSingleSegment = time; startTimeOfSingleSegment = time;
@ -385,6 +386,7 @@ public class GPXUtilities {
endTimeOfSingleSegment = 0; endTimeOfSingleSegment = 0;
} }
} }
}
startTime = Math.min(startTime, time); startTime = Math.min(startTime, time);
endTime = Math.max(endTime, time); endTime = Math.max(endTime, time);
} }

View file

@ -302,6 +302,9 @@ public class SplitSegmentFragment extends OsmAndListFragment {
} }
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) { private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
if (getMyActivity() == null) {
return null;
}
List<GpxDisplayGroup> result = getMyActivity().getGpxFile(useDisplayGroups); List<GpxDisplayGroup> result = getMyActivity().getGpxFile(useDisplayGroups);
List<GpxDisplayGroup> groups = new ArrayList<>(); List<GpxDisplayGroup> groups = new ArrayList<>();
for (GpxDisplayGroup group : result) { for (GpxDisplayGroup group : result) {
@ -613,17 +616,21 @@ public class SplitSegmentFragment extends OsmAndListFragment {
} }
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
if (mSelectedGpxFile != null) {
mSelectedGpxFile.setDisplayGroups(getDisplayGroups());
}
if (!mActivity.isFinishing()) { if (!mActivity.isFinishing()) {
mActivity.setProgressBarIndeterminateVisibility(false); mActivity.setSupportProgressBarIndeterminateVisibility(false);
}
if (mSelectedGpxFile != null) {
List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups == null) {
return;
}
mSelectedGpxFile.setDisplayGroups(groups);
} }
updateContent(); updateContent();
} }
protected void onPreExecute() { protected void onPreExecute() {
mActivity.setProgressBarIndeterminateVisibility(true); mActivity.setSupportProgressBarIndeterminateVisibility(true);
} }
@Override @Override

View file

@ -134,7 +134,6 @@ public class TrackSegmentFragment extends OsmAndListFragment {
private Paint paintIcon; private Paint paintIcon;
private Bitmap pointSmall; private Bitmap pointSmall;
private GpxDisplayItem generalDisplayItem; private GpxDisplayItem generalDisplayItem;
private View splitIntervalView;
private ImageView imageView; private ImageView imageView;
private RotatedTileBox rotatedTileBox; private RotatedTileBox rotatedTileBox;
@ -294,7 +293,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
}); });
final View splitColorView = headerView.findViewById(R.id.split_color_view); final View splitColorView = headerView.findViewById(R.id.split_color_view);
final View divider = headerView.findViewById(R.id.divider); final View divider = headerView.findViewById(R.id.divider);
splitIntervalView = headerView.findViewById(R.id.split_interval_view); final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
final View colorView = headerView.findViewById(R.id.color_view); final View colorView = headerView.findViewById(R.id.color_view);
final SwitchCompat vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle); final SwitchCompat vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle);
final ProgressBar progressBar = (ProgressBar) headerView.findViewById(R.id.mapLoadProgress); final ProgressBar progressBar = (ProgressBar) headerView.findViewById(R.id.mapLoadProgress);
@ -468,8 +467,12 @@ public class TrackSegmentFragment extends OsmAndListFragment {
} }
public void updateSplitView() { public void updateSplitView() {
prepareSplitIntervalAdapterData(); SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), ((SwitchCompat)headerView.findViewById(R.id.showOnMapToggle)).isChecked(), false);
updateSplitIntervalView(splitIntervalView); final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, ((SwitchCompat)headerView.findViewById(R.id.showOnMapToggle)).isChecked() ? sf : null);
}
updateSplitIntervalView(headerView.findViewById(R.id.split_interval_view));
} }
private void refreshTrackBitmap() { private void refreshTrackBitmap() {
@ -678,6 +681,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
} }
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) { private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
if (getMyActivity() == null) {
return null;
}
List<GpxDisplayGroup> result = getMyActivity().getGpxFile(useDisplayGroups); List<GpxDisplayGroup> result = getMyActivity().getGpxFile(useDisplayGroups);
List<GpxDisplayGroup> groups = new ArrayList<>(); List<GpxDisplayGroup> groups = new ArrayList<>();
for (GpxDisplayGroup group : result) { for (GpxDisplayGroup group : result) {
@ -712,6 +718,10 @@ public class TrackSegmentFragment extends OsmAndListFragment {
adapter.setNotifyOnChange(true); adapter.setNotifyOnChange(true);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
updateHeader(); updateHeader();
if (getGpx() != null && (getGpx().tracks.size() > 0 || getGpx().routes.size() > 0)) {
(headerView.findViewById(R.id.split_color_view)).setVisibility(View.VISIBLE);
(headerView.findViewById(R.id.divider)).setVisibility(View.VISIBLE);
}
} }
protected List<GpxDisplayItem> flatten(List<GpxDisplayGroup> groups) { protected List<GpxDisplayItem> flatten(List<GpxDisplayGroup> groups) {
@ -990,9 +1000,17 @@ public class TrackSegmentFragment extends OsmAndListFragment {
} }
} else { } else {
float distance = pos * dataSet.getDivX(); float distance = pos * dataSet.getDivX();
for (WptPt p : segment.points) { double previousSplitDistance = 0;
if (p.distance >= distance) { for (int i = 0; i < segment.points.size(); i++) {
wpt = p; WptPt currentPoint = segment.points.get(i);
if (i != 0) {
WptPt previousPoint = segment.points.get(i - 1);
if (currentPoint.distance < previousPoint.distance) {
previousSplitDistance += previousPoint.distance;
}
}
if (previousSplitDistance + currentPoint.distance >= distance) {
wpt = currentPoint;
break; break;
} }
} }
@ -1496,19 +1514,23 @@ public class TrackSegmentFragment extends OsmAndListFragment {
} }
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
if (!mActivity.isFinishing()) {
mActivity.setSupportProgressBarIndeterminateVisibility(false);
}
if (mSelectedGpxFile != null) { if (mSelectedGpxFile != null) {
mSelectedGpxFile.setDisplayGroups(getDisplayGroups()); List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups == null) {
return;
}
mSelectedGpxFile.setDisplayGroups(groups);
} }
if (mFragment.isVisible()) { if (mFragment.isVisible()) {
//mFragment.updateContent(); //mFragment.updateContent();
} }
if (!mActivity.isFinishing()) {
mActivity.setProgressBarIndeterminateVisibility(false);
}
} }
protected void onPreExecute() { protected void onPreExecute() {
mActivity.setProgressBarIndeterminateVisibility(true); mActivity.setSupportProgressBarIndeterminateVisibility(true);
} }
@Override @Override