Gpx info fixes

This commit is contained in:
Alexey Kulish 2017-02-27 22:18:38 +03:00
parent 82ea70cf7e
commit c692612d87
10 changed files with 263 additions and 146 deletions

View file

@ -2,5 +2,8 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<corners android:radius="4dp" /> <corners android:radius="4dp" />
<solid android:color="@color/gpx_chart_blue"/> <solid android:color="?attr/bg_color"/>
<stroke
android:width="1dp"
android:color="#808080" />
</shape> </shape>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="@color/gpx_chart_orange"/>
</shape>

View file

@ -7,19 +7,18 @@
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="horizontal"
android:background="@drawable/chart_marker_background">
<LinearLayout <LinearLayout
android:id="@+id/text_alt_container" android:id="@+id/text_alt_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_marginTop="2dp"
android:paddingTop="2dp" android:paddingTop="2dp"
android:paddingBottom="2dp" android:paddingBottom="2dp"
android:paddingLeft="6dp" android:paddingLeft="6dp"
android:paddingRight="6dp" android:paddingRight="6dp">
android:background="@drawable/chart_marker_blue_background">
<TextView <TextView
android:id="@+id/text_alt_value" android:id="@+id/text_alt_value"
@ -27,7 +26,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="100 " android:text="100 "
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
android:textColor="@android:color/white" android:textColor="@color/gpx_chart_blue"
android:textStyle="bold" android:textStyle="bold"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true"/> android:singleLine="true"/>
@ -38,23 +37,29 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="m" android:text="m"
android:textSize="@dimen/default_sub_text_size" android:textSize="@dimen/default_sub_text_size"
android:textColor="@android:color/white" android:textColor="?android:attr/textColorSecondary"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true"/> android:singleLine="true"/>
</LinearLayout> </LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_marginBottom="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout <LinearLayout
android:id="@+id/text_spd_container" android:id="@+id/text_spd_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_marginTop="2dp"
android:paddingTop="2dp" android:paddingTop="2dp"
android:paddingBottom="2dp" android:paddingBottom="2dp"
android:paddingLeft="6dp" android:paddingLeft="6dp"
android:paddingRight="6dp" android:paddingRight="6dp">
android:background="@drawable/chart_marker_orange_background">
<TextView <TextView
android:id="@+id/text_spd_value" android:id="@+id/text_spd_value"
@ -62,7 +67,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="100 " android:text="100 "
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
android:textColor="@android:color/white" android:textColor="@color/gpx_chart_orange"
android:textStyle="bold" android:textStyle="bold"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true"/> android:singleLine="true"/>
@ -73,7 +78,40 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="km/h" android:text="km/h"
android:textSize="@dimen/default_sub_text_size" android:textSize="@dimen/default_sub_text_size"
android:textColor="@android:color/white" android:textColor="?android:attr/textColorSecondary"
android:ellipsize="end"
android:singleLine="true"/>
</LinearLayout>
<LinearLayout
android:id="@+id/text_slp_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:paddingLeft="6dp"
android:paddingRight="6dp">
<TextView
android:id="@+id/text_slp_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="100 "
android:textSize="@dimen/default_desc_text_size"
android:textColor="@color/gpx_chart_green"
android:textStyle="bold"
android:ellipsize="end"
android:singleLine="true"/>
<TextView
android:id="@+id/text_slp_units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="%"
android:textSize="@dimen/default_sub_text_size"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true"/> android:singleLine="true"/>
@ -81,5 +119,4 @@
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -15,11 +15,16 @@
android:scaleType="center" android:scaleType="center"
android:visibility="gone"/> android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="?attr/bg_color">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:background="?attr/bg_color"
android:gravity="center_vertical"> android:gravity="center_vertical">
<LinearLayout <LinearLayout
@ -52,11 +57,17 @@
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:background="?attr/bg_color"
android:gravity="center_vertical"> android:gravity="center_vertical">
<LinearLayout <LinearLayout
@ -135,3 +146,5 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout>

View file

@ -230,5 +230,8 @@
<color name="gpx_chart_blue">#2f7af5</color> <color name="gpx_chart_blue">#2f7af5</color>
<color name="gpx_chart_orange">#ff8800</color> <color name="gpx_chart_orange">#ff8800</color>
<color name="gpx_chart_green">#23b03b</color> <color name="gpx_chart_green">#23b03b</color>
<color name="gpx_chart_blue_grid">#c32561c2</color>
<color name="gpx_chart_orange_grid">#c3b35f00</color>
<color name="gpx_chart_green_grid">#c3197d2a</color>
</resources> </resources>

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="gpx_track">Track</string>
<string name="max_speed">Max speed</string> <string name="max_speed">Max speed</string>
<string name="average_speed">Average speed</string> <string name="average_speed">Average speed</string>
<string name="shared_string_time_moving">Time moving</string> <string name="shared_string_time_moving">Time moving</string>

View file

@ -45,6 +45,7 @@ public class TrackActivity extends TabActivity {
ViewPager mViewPager; ViewPager mViewPager;
private long modifiedTime = -1; private long modifiedTime = -1;
private List<GpxDisplayGroup> displayGroups; private List<GpxDisplayGroup> displayGroups;
private List<GpxDisplayGroup> originalGroups = new ArrayList<>();
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@ -108,7 +109,7 @@ public class TrackActivity extends TabActivity {
} }
} }
((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab( ((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab(
getTabIndicator(R.string.info_button, TrackSegmentFragment.class)); getTabIndicator(R.string.gpx_track, TrackSegmentFragment.class));
if (isHavingWayPoints() || isHavingRoutePoints()) { if (isHavingWayPoints() || isHavingRoutePoints()) {
((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab( ((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab(
getTabIndicator(R.string.points, TrackPointFragment.class)); getTabIndicator(R.string.points, TrackPointFragment.class));
@ -132,7 +133,7 @@ public class TrackActivity extends TabActivity {
} }
} }
public List<GpxDisplayGroup> getGpxFile() { public List<GpxDisplayGroup> getGpxFile(boolean useDisplayGroups) {
if (gpxFile == null) { if (gpxFile == null) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -140,6 +141,10 @@ public class TrackActivity extends TabActivity {
modifiedTime = gpxFile.modifiedTime; modifiedTime = gpxFile.modifiedTime;
GpxSelectionHelper selectedGpxHelper = ((OsmandApplication) getApplication()).getSelectedGpxHelper(); GpxSelectionHelper selectedGpxHelper = ((OsmandApplication) getApplication()).getSelectedGpxHelper();
displayGroups = selectedGpxHelper.collectDisplayGroups(gpxFile); displayGroups = selectedGpxHelper.collectDisplayGroups(gpxFile);
originalGroups.clear();
for (GpxDisplayGroup g : displayGroups) {
originalGroups.add(g.cloneInstance());
}
if (file != null) { if (file != null) {
SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path); SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path);
if (sf != null && file != null && sf.getDisplayGroups() != null) { if (sf != null && file != null && sf.getDisplayGroups() != null) {
@ -147,7 +152,11 @@ public class TrackActivity extends TabActivity {
} }
} }
} }
if (useDisplayGroups) {
return displayGroups; return displayGroups;
} else {
return originalGroups;
}
} }
@Override @Override

View file

@ -1004,6 +1004,8 @@ public class GpxUiHelper {
} else { } else {
yAxis = mChart.getAxisLeft(); yAxis = mChart.getAxisLeft();
} }
yAxis.setTextColor(ActivityCompat.getColor(mChart.getContext(), R.color.gpx_chart_blue));
yAxis.setGridColor(ActivityCompat.getColor(mChart.getContext(), R.color.gpx_chart_blue_grid));
yAxis.setGranularity(1f); yAxis.setGranularity(1f);
yAxis.setValueFormatter(new IAxisValueFormatter() { yAxis.setValueFormatter(new IAxisValueFormatter() {
@ -1017,17 +1019,17 @@ public class GpxUiHelper {
List<Elevation> elevationData = analysis.elevationData; List<Elevation> elevationData = analysis.elevationData;
float nextX = 0; float nextX = 0;
float nextY; float nextY;
float prevElev = -80000; //float prevElev = -80000;
float gist = 1.5f; //float gist = 1.5f;
for (Elevation e : elevationData) { for (Elevation e : elevationData) {
if (e.distance > 0) { if (e.distance > 0) {
nextX += (float) e.distance / divX; nextX += (float) e.distance / divX;
nextY = (float) (e.elevation * convEle); nextY = (float) (e.elevation * convEle);
if (Math.abs(prevElev - e.elevation) < gist) { //if (Math.abs(prevElev - e.elevation) < gist) {
continue; // continue;
} else { //} else {
prevElev = (float) e.elevation; // prevElev = (float) e.elevation;
} //}
values.add(new Entry(nextX, nextY)); values.add(new Entry(nextX, nextY));
} }
} }
@ -1134,6 +1136,8 @@ public class GpxUiHelper {
} else { } else {
yAxis = mChart.getAxisLeft(); yAxis = mChart.getAxisLeft();
} }
yAxis.setTextColor(ActivityCompat.getColor(mChart.getContext(), R.color.gpx_chart_orange));
yAxis.setGridColor(ActivityCompat.getColor(mChart.getContext(), R.color.gpx_chart_orange_grid));
yAxis.setAxisMinimum(0f); yAxis.setAxisMinimum(0f);
yAxis.setValueFormatter(new IAxisValueFormatter() { yAxis.setValueFormatter(new IAxisValueFormatter() {
@ -1246,6 +1250,8 @@ public class GpxUiHelper {
} else { } else {
yAxis = mChart.getAxisLeft(); yAxis = mChart.getAxisLeft();
} }
yAxis.setTextColor(ActivityCompat.getColor(mChart.getContext(), R.color.gpx_chart_green));
yAxis.setGridColor(ActivityCompat.getColor(mChart.getContext(), R.color.gpx_chart_green_grid));
yAxis.setGranularity(1f); yAxis.setGranularity(1f);
yAxis.setValueFormatter(new IAxisValueFormatter() { yAxis.setValueFormatter(new IAxisValueFormatter() {
@ -1264,13 +1270,20 @@ public class GpxUiHelper {
float nextYM; float nextYM;
float prevXM; float prevXM;
float prevYM; float prevYM;
float prevElevM = -80000;
float prevDistM = -1; float prevDistM = -1;
float gist = 1.5f; //float prevElevM = -80000;
//float gist = 1.5f; // 1.5 meters
float delta = 30f; // 30 meters
float d; float d;
if (elevationData.size() > 1) { if (elevationData.size() > 1) {
Elevation e0 = elevationData.get(0); Elevation e0 = elevationData.get(0);
nextXM = e0.distance > 0 ? (float) e0.distance : 0f; d = (float) e0.distance;
if (d > delta) {
nextXM = d / 2f;
prevDistM = d;
} else {
nextXM = 0f;
}
nextYM = 0; nextYM = 0;
prevXM = nextXM; prevXM = nextXM;
prevYM = nextYM; prevYM = nextYM;
@ -1279,21 +1292,25 @@ public class GpxUiHelper {
for (int i = 1; i < elevationData.size(); i++) { for (int i = 1; i < elevationData.size(); i++) {
Elevation e = elevationData.get(i); Elevation e = elevationData.get(i);
if (e.distance > 0) { if (e.distance > 0) {
d = (float) e.distance; d += (float) e.distance;
if (d < delta && i < elevationData.size() - 1) {
continue;
}
if (prevDistM < 0) { if (prevDistM < 0) {
nextDistM = d / 2f; nextDistM = d / 2f;
} else { } else {
nextDistM = prevDistM / 2f + d / 2f; nextDistM = prevDistM / 2f + d / 2f;
} }
prevDistM = d; prevDistM = d;
d = 0;
nextXM += nextDistM; nextXM += nextDistM;
nextYM = (float) e.elevation; nextYM = (float) e.elevation;
if (Math.abs(prevElevM - nextYM) < gist) { //if (Math.abs(prevElevM - nextYM) < gist) {
nextX += nextDistM / divX; // nextX += nextDistM / divX;
continue; // continue;
} else { //} else {
prevElevM = nextYM; // prevElevM = nextYM;
} //}
if (nextX == 0) { if (nextX == 0) {
prevXM = nextXM; prevXM = nextXM;
prevYM = nextYM; prevYM = nextYM;
@ -1301,7 +1318,7 @@ public class GpxUiHelper {
} }
nextX += nextDistM / divX; nextX += nextDistM / divX;
nextY = (nextYM - prevYM) / (nextXM - prevXM) * 100f; nextY = (nextYM - prevYM) / (nextXM - prevXM) * 100f;
if (nextXM - prevXM > 30 && Math.abs(nextY) < 120) { if (Math.abs(nextY) < 120) {
values.add(new Entry(nextX, nextY)); values.add(new Entry(nextX, nextY));
prevXM = nextXM; prevXM = nextXM;
prevYM = nextYM; prevYM = nextYM;
@ -1388,11 +1405,13 @@ public class GpxUiHelper {
private View textAltView; private View textAltView;
private View textSpdView; private View textSpdView;
private View textSlpView;
public GPXMarkerView(Context context) { public GPXMarkerView(Context context) {
super(context, R.layout.chart_marker_view); super(context, R.layout.chart_marker_view);
textAltView = findViewById(R.id.text_alt_container); textAltView = findViewById(R.id.text_alt_container);
textSpdView = findViewById(R.id.text_spd_container); textSpdView = findViewById(R.id.text_spd_container);
textSlpView = findViewById(R.id.text_slp_container);
} }
// callbacks everytime the MarkerView is redrawn, can be used to update the // callbacks everytime the MarkerView is redrawn, can be used to update the
@ -1410,19 +1429,29 @@ public class GpxUiHelper {
((TextView) textAltView.findViewById(R.id.text_alt_units)).setText(units); ((TextView) textAltView.findViewById(R.id.text_alt_units)).setText(units);
textAltView.setVisibility(VISIBLE); textAltView.setVisibility(VISIBLE);
textSpdView.setVisibility(GONE); textSpdView.setVisibility(GONE);
textSlpView.setVisibility(GONE);
break; break;
case SPEED: case SPEED:
((TextView) textSpdView.findViewById(R.id.text_spd_value)).setText(value); ((TextView) textSpdView.findViewById(R.id.text_spd_value)).setText(value);
((TextView) textSpdView.findViewById(R.id.text_spd_units)).setText(units); ((TextView) textSpdView.findViewById(R.id.text_spd_units)).setText(units);
textAltView.setVisibility(GONE); textAltView.setVisibility(GONE);
textSpdView.setVisibility(VISIBLE); textSpdView.setVisibility(VISIBLE);
textSlpView.setVisibility(GONE);
break;
case SLOPE:
((TextView) textSlpView.findViewById(R.id.text_slp_value)).setText(value);
textAltView.setVisibility(GONE);
textSpdView.setVisibility(GONE);
textSlpView.setVisibility(VISIBLE);
break; break;
} }
findViewById(R.id.divider).setVisibility(GONE);
} else if (chartData.getDataSetCount() == 2) { } else if (chartData.getDataSetCount() == 2) {
OrderedLineDataSet dataSet1 = (OrderedLineDataSet) chartData.getDataSetByIndex(0); OrderedLineDataSet dataSet1 = (OrderedLineDataSet) chartData.getDataSetByIndex(0);
OrderedLineDataSet dataSet2 = (OrderedLineDataSet) chartData.getDataSetByIndex(1); OrderedLineDataSet dataSet2 = (OrderedLineDataSet) chartData.getDataSetByIndex(1);
int altSetIndex = -1; int altSetIndex = -1;
int spdSetIndex = -1; int spdSetIndex = -1;
int slpSetIndex = -1;
switch (dataSet1.getDataSetType()) { switch (dataSet1.getDataSetType()) {
case ALTITUDE: case ALTITUDE:
altSetIndex = 0; altSetIndex = 0;
@ -1430,6 +1459,9 @@ public class GpxUiHelper {
case SPEED: case SPEED:
spdSetIndex = 0; spdSetIndex = 0;
break; break;
case SLOPE:
slpSetIndex = 0;
break;
} }
switch (dataSet2.getDataSetType()) { switch (dataSet2.getDataSetType()) {
case ALTITUDE: case ALTITUDE:
@ -1438,6 +1470,9 @@ public class GpxUiHelper {
case SPEED: case SPEED:
spdSetIndex = 1; spdSetIndex = 1;
break; break;
case SLOPE:
slpSetIndex = 1;
break;
} }
if (altSetIndex != -1) { if (altSetIndex != -1) {
Entry eAlt = chartData.getEntryForHighlight(new Highlight(e.getX(), Float.NaN, altSetIndex)); Entry eAlt = chartData.getEntryForHighlight(new Highlight(e.getX(), Float.NaN, altSetIndex));
@ -1455,26 +1490,44 @@ public class GpxUiHelper {
} else { } else {
textSpdView.setVisibility(GONE); textSpdView.setVisibility(GONE);
} }
if (slpSetIndex != -1) {
Entry eSlp = chartData.getEntryForHighlight(new Highlight(e.getX(), Float.NaN, slpSetIndex));
((TextView) textSlpView.findViewById(R.id.text_slp_value)).setText(Integer.toString((int) eSlp.getY()) + " ");
textSlpView.setVisibility(VISIBLE);
} else {
textSlpView.setVisibility(GONE);
}
findViewById(R.id.divider).setVisibility(VISIBLE);
} else { } else {
textAltView.setVisibility(GONE); textAltView.setVisibility(GONE);
textSpdView.setVisibility(GONE); textSpdView.setVisibility(GONE);
textSlpView.setVisibility(GONE);
findViewById(R.id.divider).setVisibility(GONE);
} }
super.refreshContent(e, highlight); super.refreshContent(e, highlight);
} }
@Override @Override
public MPPointF getOffset() { public MPPointF getOffset() {
if (getChartView().getData().getDataSetCount() > 1) { if (getChartView().getData().getDataSetCount() == 2) {
return new MPPointF(-(textAltView.getWidth() / 2), 0); int x = findViewById(R.id.divider).getLeft();
return new MPPointF(-x - AndroidUtils.dpToPx(getContext(), .5f), 0);
} else { } else {
return new MPPointF(-(getWidth() / 2), 0); return new MPPointF(-getWidth() / 2f, 0);
} }
} }
@Override @Override
public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) { public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) {
int margin = AndroidUtils.dpToPx(getContext(), 3f);
MPPointF offset = getOffset(); MPPointF offset = getOffset();
offset.y = -posY; offset.y = -posY;
if (posX + offset.x - margin < 0) {
offset.x -= (offset.x + posX - margin);
}
if (posX + offset.x + getWidth() + margin > getChartView().getWidth()) {
offset.x -= (getWidth() - (getChartView().getWidth() - posX) + offset.x) + margin;
}
return offset; return offset;
} }
} }

View file

@ -147,7 +147,7 @@ public class TrackPointFragment extends OsmAndListFragment {
} }
private List<GpxDisplayGroup> filterGroups(GpxDisplayItemType[] types) { private List<GpxDisplayGroup> filterGroups(GpxDisplayItemType[] types) {
List<GpxDisplayGroup> result = getMyActivity().getGpxFile(); List<GpxDisplayGroup> result = getMyActivity().getGpxFile(false);
List<GpxDisplayGroup> groups = new ArrayList<>(); List<GpxDisplayGroup> groups = new ArrayList<>();
for (GpxDisplayGroup group : result) { for (GpxDisplayGroup group : result) {
boolean add = types == null || hasFilterType(types, group.getType()); boolean add = types == null || hasFilterType(types, group.getType());

View file

@ -225,7 +225,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
public void onClick(View v) { public void onClick(View v) {
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), vis.isChecked(), false); SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), vis.isChecked(), false);
if (vis.isChecked() && sf.getGpxFile() != null) { if (vis.isChecked() && sf.getGpxFile() != null) {
final List<GpxDisplayGroup> groups = getGroups(); final List<GpxDisplayGroup> groups = getOriginalGroups();
if (groups.size() > 0 && groups.get(0).getModifiableList().size() > 0) { if (groups.size() > 0 && groups.get(0).getModifiableList().size() > 0) {
GpxDisplayItem item = groups.get(0).getModifiableList().get(0); GpxDisplayItem item = groups.get(0).getModifiableList().get(0);
app.getSettings().setMapLocationToShow(item.locationStart.lat, item.locationStart.lon, app.getSettings().setMapLocationToShow(item.locationStart.lat, item.locationStart.lon,
@ -309,7 +309,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedSplitInterval = position; selectedSplitInterval = position;
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), vis.isChecked(), false); SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), vis.isChecked(), false);
final List<GpxDisplayGroup> groups = getGroups(); final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) { if (groups.size() > 0) {
updateSplit(groups, vis.isChecked() ? sf : null); updateSplit(groups, vis.isChecked() ? sf : null);
} }
@ -323,8 +323,12 @@ public class TrackSegmentFragment extends OsmAndListFragment {
} }
} }
private List<GpxDisplayGroup> getGroups() { private List<GpxDisplayGroup> getOriginalGroups() {
return filterGroups(); return filterGroups(false);
}
private List<GpxDisplayGroup> getDisplayGroups() {
return filterGroups(true);
} }
private void setupSplitIntervalView(View view) { private void setupSplitIntervalView(View view) {
@ -332,7 +336,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
final TextView text = (TextView) view.findViewById(R.id.split_interval_text); final TextView text = (TextView) view.findViewById(R.id.split_interval_text);
final ImageView img = (ImageView) view.findViewById(R.id.split_interval_arrow); final ImageView img = (ImageView) view.findViewById(R.id.split_interval_arrow);
int colorId; int colorId;
final List<GpxDisplayGroup> groups = getGroups(); final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) { if (groups.size() > 0) {
colorId = app.getSettings().isLightContent() ? colorId = app.getSettings().isLightContent() ?
R.color.primary_text_light : R.color.primary_text_dark; R.color.primary_text_light : R.color.primary_text_dark;
@ -387,8 +391,8 @@ public class TrackSegmentFragment extends OsmAndListFragment {
return false; return false;
} }
private List<GpxDisplayGroup> filterGroups() { private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
List<GpxDisplayGroup> result = getMyActivity().getGpxFile(); List<GpxDisplayGroup> result = getMyActivity().getGpxFile(useDisplayGroups);
List<GpxDisplayGroup> groups = new ArrayList<>(); List<GpxDisplayGroup> groups = new ArrayList<>();
for (GpxDisplayGroup group : result) { for (GpxDisplayGroup group : result) {
boolean add = hasFilterType(group.getType()); boolean add = hasFilterType(group.getType());
@ -425,7 +429,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
protected void updateContent() { protected void updateContent() {
adapter.clear(); adapter.clear();
List<GpxDisplayGroup> groups = filterGroups(); List<GpxDisplayGroup> groups = getOriginalGroups();
adapter.setNotifyOnChange(false); adapter.setNotifyOnChange(false);
for (GpxDisplayItem i : flatten(groups)) { for (GpxDisplayItem i : flatten(groups)) {
adapter.add(i); adapter.add(i);
@ -443,7 +447,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
} }
private void prepareSplitIntervalAdapterData() { private void prepareSplitIntervalAdapterData() {
final List<GpxDisplayGroup> groups = getGroups(); final List<GpxDisplayGroup> groups = getDisplayGroups();
options.add(app.getString(R.string.shared_string_none)); options.add(app.getString(R.string.shared_string_none));
distanceSplit.add(-1d); distanceSplit.add(-1d);
@ -873,7 +877,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
((TextView) view.findViewById(R.id.time_moving_text)) ((TextView) view.findViewById(R.id.time_moving_text))
.setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000), app.accessibilityEnabled())); .setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000), app.accessibilityEnabled()));
((TextView) view.findViewById(R.id.distance_text)) ((TextView) view.findViewById(R.id.distance_text))
.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app)); .setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistanceMoving, app));
} else { } else {
chart.setVisibility(View.GONE); chart.setVisibility(View.GONE);
@ -999,10 +1003,10 @@ public class TrackSegmentFragment extends OsmAndListFragment {
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
if (mSelectedGpxFile != null) { if (mSelectedGpxFile != null) {
mSelectedGpxFile.setDisplayGroups(filterGroups()); mSelectedGpxFile.setDisplayGroups(getDisplayGroups());
} }
if (mFragment.isVisible()) { if (mFragment.isVisible()) {
mFragment.updateContent(); //mFragment.updateContent();
} }
if (!mActivity.isFinishing()) { if (!mActivity.isFinishing()) {
mActivity.setProgressBarIndeterminateVisibility(false); mActivity.setProgressBarIndeterminateVisibility(false);