diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 480e5affa8..89734b7415 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -48,9 +48,9 @@ import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.myplaces.GPXItemPagerAdapter; +import net.osmand.plus.myplaces.GPXTabItemType; import net.osmand.plus.myplaces.SegmentActionsListener; import net.osmand.plus.myplaces.SegmentGPXAdapter; import net.osmand.plus.settings.backend.OsmandSettings; @@ -71,18 +71,19 @@ import java.util.List; import static net.osmand.AndroidUtils.getSecondaryTextColorId; import static net.osmand.AndroidUtils.setPadding; import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL; -import static net.osmand.plus.track.GpxBlockStatisticsBuilder.INIT_BLOCKS_ALTITUDE; -import static net.osmand.plus.track.GpxBlockStatisticsBuilder.INIT_BLOCKS_GENERAL; -import static net.osmand.plus.track.GpxBlockStatisticsBuilder.INIT_BLOCKS_SPEED; +import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_ALTITUDE; +import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_GENERAL; +import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_SPEED; public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment implements SegmentActionsListener { public static final String TAG = TripRecordingBottomSheet.class.getSimpleName(); private static final Log LOG = PlatformUtil.getLog(TripRecordingBottomSheet.class); public static final String UPDATE_TRACK_ICON = "update_track_icon"; + public static final String UPDATE_DYNAMIC_ITEMS = "update_dynamic_items"; private static final int GPS_UPDATE_INTERVAL = 1000; - private static final String[] INIT_BLOCKS_KEYS = - new String[]{INIT_BLOCKS_GENERAL, INIT_BLOCKS_ALTITUDE, INIT_BLOCKS_SPEED}; + public static final GPXTabItemType[] INIT_TAB_ITEMS = + new GPXTabItemType[]{GPX_TAB_ITEM_GENERAL, GPX_TAB_ITEM_ALTITUDE, GPX_TAB_ITEM_SPEED}; private OsmandApplication app; private OsmandSettings settings; @@ -91,16 +92,17 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl private View statusContainer; private AppCompatImageView trackAppearanceIcon; - private LinearLayout segmentsContainer; - private TrackDisplayHelper displayHelper; private TrackChartPoints trackChartPoints; private GPXItemPagerAdapter graphsAdapter; + private int graphTabPosition = 0; + private ViewGroup segmentsTabs; private GpxBlockStatisticsBuilder blockStatisticsBuilder; private SelectedGpxFile selectedGpxFile; private final Handler handler = new Handler(); private Runnable updatingGPS; + private Runnable updatingGraph; private GPXFile getGPXFile() { return selectedGpxFile.getGpxFile(); @@ -153,14 +155,14 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl } }); - segmentsContainer = itemView.findViewById(R.id.segments_container); - createSegmentsTabs(segmentsContainer); + segmentsTabs = itemView.findViewById(R.id.segments_container); + createSegmentsTabs(segmentsTabs); RecyclerView statBlocks = itemView.findViewById(R.id.block_statistics); blockStatisticsBuilder = new GpxBlockStatisticsBuilder(app, selectedGpxFile, nightMode); blockStatisticsBuilder.setBlocksView(statBlocks); blockStatisticsBuilder.setBlocksClickable(false); - blockStatisticsBuilder.setInitBlocksKey(INIT_BLOCKS_GENERAL); + blockStatisticsBuilder.setTabItem(GPX_TAB_ITEM_GENERAL); blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode))); @@ -181,8 +183,10 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl boolean wasTrackMonitored = !wasTrackMonitored(); if (!wasTrackMonitored) { blockStatisticsBuilder.stopUpdatingStatBlocks(); + stopUpdatingGraph(); } else { blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded(); + runUpdatingGraph(); } settings.SAVE_GLOBAL_TRACK_TO_GPX.set(wasTrackMonitored); updateStatus(); @@ -222,6 +226,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl super.onResume(); blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded(); runUpdatingGPS(); + runUpdatingGraph(); MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints); @@ -233,6 +238,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl super.onPause(); blockStatisticsBuilder.stopUpdatingStatBlocks(); stopUpdatingGPS(); + stopUpdatingGraph(); MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(null); @@ -248,6 +254,10 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl if (key.equals(UPDATE_TRACK_ICON)) { updateTrackIcon(app, trackAppearanceIcon); } + if (key.equals(UPDATE_DYNAMIC_ITEMS)) { + blockStatisticsBuilder.restartUpdatingStatBlocks(); + restartUpdatingGraph(); + } } } @@ -258,11 +268,11 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl } } - public void stopUpdatingGPS() { + private void stopUpdatingGPS() { handler.removeCallbacks(updatingGPS); } - public void runUpdatingGPS() { + private void runUpdatingGPS() { updatingGPS = new Runnable() { @Override public void run() { @@ -274,27 +284,30 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl handler.post(updatingGPS); } - private void recreateStatBlocks(String initBlocksKey) { - blockStatisticsBuilder.stopUpdatingStatBlocks(); - blockStatisticsBuilder.setInitBlocksKey(initBlocksKey); - blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded(); + private void stopUpdatingGraph() { + handler.removeCallbacks(updatingGraph); } - private void setupDisplayHelper() { - displayHelper = new TrackDisplayHelper(app); - if (!selectedGpxFile.isShowCurrentTrack()) { - File file = new File(getGPXFile().path); - displayHelper.setFile(file); - displayHelper.setGpxDataItem(app.getGpxDbHelper().getItem(file)); - } - displayHelper.setGpx(getGPXFile()); + private void runUpdatingGraph() { + updatingGraph = new Runnable() { + @Override + public void run() { + int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get(); + graphsAdapter.updateGraph(graphTabPosition); + AndroidUiHelper.updateVisibility(segmentsTabs, graphsAdapter.isTabsVisible()); + handler.postDelayed(this, Math.max(GPS_UPDATE_INTERVAL, interval)); + } + }; + handler.post(updatingGraph); + } + + private void restartUpdatingGraph() { + stopUpdatingGraph(); + runUpdatingGraph(); } private void createSegmentsTabs(ViewGroup viewGroup) { - viewGroup.removeAllViews(); - setupDisplayHelper(); - - View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode); + View segmentView = SegmentGPXAdapter.createGpxTabsView(null, viewGroup, this, nightMode); AndroidUiHelper.setVisibility(View.GONE, segmentView.findViewById(R.id.list_item_divider)); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs); @@ -304,17 +317,26 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl tabLayout.setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() { @Override public void onTabSelected(int position) { - recreateStatBlocks(INIT_BLOCKS_KEYS[position]); + graphTabPosition = position; + blockStatisticsBuilder.setTabItem(INIT_TAB_ITEMS[graphTabPosition]); + blockStatisticsBuilder.restartUpdatingStatBlocks(); } @Override public void onTabReselected(int position) { - recreateStatBlocks(INIT_BLOCKS_KEYS[position]); + graphTabPosition = position; + blockStatisticsBuilder.setTabItem(INIT_TAB_ITEMS[graphTabPosition]); } }); - graphsAdapter = new GPXItemPagerAdapter(app, GpxUiHelper.makeGpxDisplayItem(app, - displayHelper.getGpx()), displayHelper, nightMode, this, true); + TrackDisplayHelper displayHelper = new TrackDisplayHelper(app); + GPXFile gpxFile = getGPXFile(); + File file = new File(gpxFile.path); + displayHelper.setFile(file); + displayHelper.setGpxDataItem(app.getGpxDbHelper().getItem(file)); + displayHelper.setGpx(gpxFile); + + graphsAdapter = new GPXItemPagerAdapter(app, null, displayHelper, nightMode, this, true); graphsAdapter.setChartHMargin(getResources().getDimensionPixelSize(R.dimen.content_padding)); pager.setAdapter(graphsAdapter); @@ -596,7 +618,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl public void onPointSelected(TrkSegment segment, double lat, double lon) { if (trackChartPoints == null) { trackChartPoints = new TrackChartPoints(); - trackChartPoints.setGpx(displayHelper.getGpx()); + trackChartPoints.setGpx(getGPXFile()); } MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheet.java index 88814e4819..aeb33abf93 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheet.java @@ -11,6 +11,7 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; +import net.osmand.plus.monitoring.TripRecordingBottomSheet.DismissTargetFragment; import net.osmand.plus.monitoring.TripRecordingBottomSheet.ItemType; import androidx.annotation.NonNull; @@ -18,8 +19,9 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import static net.osmand.AndroidUtils.getPrimaryTextColorId; +import static net.osmand.plus.monitoring.TripRecordingOptionsBottomSheet.ACTION_CLEAR_DATA; -public class TripRecordingClearDataBottomSheet extends MenuBottomSheetDialogFragment implements TripRecordingBottomSheet.DismissTargetFragment { +public class TripRecordingClearDataBottomSheet extends MenuBottomSheetDialogFragment implements DismissTargetFragment { public static final String TAG = TripRecordingClearDataBottomSheet.class.getSimpleName(); @@ -111,6 +113,14 @@ public class TripRecordingClearDataBottomSheet extends MenuBottomSheetDialogFrag public void dismissTarget() { Fragment target = getTargetFragment(); if (target instanceof TripRecordingOptionsBottomSheet) { + Bundle args = target.getArguments(); + if (args != null) { + args.putBoolean(ACTION_CLEAR_DATA, true); + } else { + args = new Bundle(); + args.putBoolean(ACTION_CLEAR_DATA, true); + target.setArguments(args); + } ((TripRecordingOptionsBottomSheet) target).dismiss(); } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java index cff99d9daa..6739187152 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java @@ -12,6 +12,7 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; +import net.osmand.plus.monitoring.TripRecordingBottomSheet.DismissTargetFragment; import net.osmand.plus.monitoring.TripRecordingBottomSheet.ItemType; import androidx.annotation.NonNull; @@ -21,7 +22,7 @@ import androidx.fragment.app.FragmentManager; import static net.osmand.AndroidUtils.getPrimaryTextColorId; import static net.osmand.plus.monitoring.TripRecordingOptionsBottomSheet.ACTION_STOP_AND_DISMISS; -public class TripRecordingDiscardBottomSheet extends MenuBottomSheetDialogFragment implements TripRecordingBottomSheet.DismissTargetFragment { +public class TripRecordingDiscardBottomSheet extends MenuBottomSheetDialogFragment implements DismissTargetFragment { public static final String TAG = TripRecordingDiscardBottomSheet.class.getSimpleName(); @@ -67,10 +68,15 @@ public class TripRecordingDiscardBottomSheet extends MenuBottomSheetDialogFragme dismiss(); Fragment target = getTargetFragment(); - if (target != null) { - Bundle args = new Bundle(); - args.putBoolean(ACTION_STOP_AND_DISMISS, true); - target.setArguments(args); + if (target instanceof TripRecordingOptionsBottomSheet) { + Bundle args = target.getArguments(); + if (args != null) { + args.putBoolean(ACTION_STOP_AND_DISMISS, true); + } else { + args = new Bundle(); + args.putBoolean(ACTION_STOP_AND_DISMISS, true); + target.setArguments(args); + } } dismissTarget(); } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java index 994b3034d9..6004adb74a 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java @@ -26,7 +26,7 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; -import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.monitoring.TripRecordingBottomSheet.DismissTargetFragment; import net.osmand.plus.monitoring.TripRecordingBottomSheet.ItemType; import net.osmand.plus.myplaces.SaveCurrentTrackTask; import net.osmand.plus.settings.backend.OsmandSettings; @@ -34,11 +34,13 @@ import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.util.Algorithms; import static net.osmand.AndroidUtils.getPrimaryTextColorId; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.UPDATE_DYNAMIC_ITEMS; -public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragment implements TripRecordingBottomSheet.DismissTargetFragment { +public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragment implements DismissTargetFragment { public static final String TAG = TripRecordingOptionsBottomSheet.class.getSimpleName(); public static final String ACTION_STOP_AND_DISMISS = "action_stop_and_discard"; + public static final String ACTION_CLEAR_DATA = "action_clear_data"; private static final int SAVE_UPDATE_INTERVAL = 1000; private OsmandApplication app; @@ -210,8 +212,10 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme @Override public void run() { String time = getTimeTrackSaved(); - TripRecordingBottomSheet.createItem(app, nightMode, buttonSave, ItemType.SAVE, hasDataToSave(), !Algorithms.isEmpty(time) ? time : null); - TripRecordingBottomSheet.createItem(app, nightMode, buttonClear, ItemType.CLEAR_DATA, hasDataToSave(), null); + TripRecordingBottomSheet.createItem(app, nightMode, buttonSave, ItemType.SAVE, + hasDataToSave(), !Algorithms.isEmpty(time) ? time : null); + TripRecordingBottomSheet.createItem(app, nightMode, buttonClear, ItemType.CLEAR_DATA, + hasDataToSave(), null); handler.postDelayed(this, SAVE_UPDATE_INTERVAL); } }; @@ -255,9 +259,14 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme if (mapActivity != null && plugin != null) { stopUpdatingTimeTrackSaved(); plugin.saveCurrentTrack(null, mapActivity, false, true); - Bundle args = new Bundle(); - args.putBoolean(ACTION_STOP_AND_DISMISS, true); - setArguments(args); + Bundle args = getArguments(); + if (args != null) { + args.putBoolean(ACTION_STOP_AND_DISMISS, true); + } else { + args = new Bundle(); + args.putBoolean(ACTION_STOP_AND_DISMISS, true); + setArguments(args); + } dismiss(); dismissTarget(); } @@ -273,12 +282,22 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme return false; } + private boolean isCleared() { + Bundle args = getArguments(); + if (args != null) { + return args.getBoolean(ACTION_CLEAR_DATA); + } + return false; + } + @Override public void dismissTarget() { Fragment target = getTargetFragment(); if (target instanceof TripRecordingBottomSheet) { if (isDiscard()) { ((TripRecordingBottomSheet) target).dismiss(); + } else if (isCleared()) { + ((TripRecordingBottomSheet) target).show(UPDATE_DYNAMIC_ITEMS); } else { ((TripRecordingBottomSheet) target).show(); } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index b5f33884ac..a2eaae19d0 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -1290,13 +1290,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement // local_indexes_cat_gpx now obsolete in new UI screen which shows only GPX data // if (Algorithms.objectEquals(getActivity().getString(R.string.local_indexes_cat_gpx) + " " + // g.subfolder, cat)) { - if (objectEquals("" + g.subfolder, cat)) { + if (objectEquals(g.subfolder, cat)) { found = i; break; } } if (found != -1) { data.get(category.get(found)).remove(g); + selected.remove(g); } } } @@ -1507,17 +1508,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement int total = 0; for (GpxInfo info : params) { if (!isCancelled() && (info.gpx == null || !info.gpx.showCurrentTrack)) { - boolean successfull; - successfull = removeAllFiles(info.file); - app.getGpxDbHelper().remove(info.file); + boolean successful = FileUtils.removeGpxFile(app, info.file); total++; - if (successfull) { + if (successful) { count++; publishProgress(info); } } } - return app.getString(R.string.local_index_items_deleted, count, total); + return getString(R.string.local_index_items_deleted, count, total); } @Override diff --git a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java index 34232a8c6d..8f0c5a1dc5 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java @@ -12,6 +12,7 @@ import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.widget.SwitchCompat; import androidx.viewpager.widget.PagerAdapter; @@ -33,6 +34,7 @@ import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -50,6 +52,7 @@ import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionI import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; +import java.io.File; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -63,10 +66,13 @@ import static net.osmand.plus.helpers.GpxUiHelper.LineGraphType.ALTITUDE; import static net.osmand.plus.helpers.GpxUiHelper.LineGraphType.SLOPE; import static net.osmand.plus.helpers.GpxUiHelper.LineGraphType.SPEED; import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_ALTITUDE; +import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_GENERAL; import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_SPEED; public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvider, ViewAtPositionInterface { + private static final int CHART_LABEL_COUNT = 4; + private OsmandApplication app; private UiUtilities iconsCache; private TrackDisplayHelper displayHelper; @@ -75,6 +81,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid private WptPt selectedWpt; private TrkSegment segment; private GpxDisplayItem gpxItem; + private GPXTrackAnalysis analysis; private GPXTabItemType[] tabTypes; private SparseArray views = new SparseArray<>(); @@ -89,8 +96,12 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid this.chartHMargin = chartHMargin; } + private boolean isShowCurrentTrack() { + return displayHelper.getGpx() != null && displayHelper.getGpx().showCurrentTrack; + } + public GPXItemPagerAdapter(@NonNull OsmandApplication app, - @NonNull GpxDisplayItem gpxItem, + @Nullable GpxDisplayItem gpxItem, @NonNull TrackDisplayHelper displayHelper, boolean nightMode, @NonNull SegmentActionsListener actionsListener, @@ -98,22 +109,45 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid super(); this.app = app; this.gpxItem = gpxItem; - this.nightMode = nightMode; this.displayHelper = displayHelper; + this.nightMode = nightMode; this.actionsListener = actionsListener; this.onlyGraphs = onlyGraphs; iconsCache = app.getUIUtilities(); + + updateAnalysis(); fetchTabTypes(); } + private void updateAnalysis() { + analysis = null; + if (isShowCurrentTrack()) { + GPXFile gpxFile = displayHelper.getGpx(); + if (gpxFile != null && !gpxFile.isEmpty()) { + analysis = gpxFile.getAnalysis(0); + gpxItem = GpxUiHelper.makeGpxDisplayItem(app, gpxFile); + } + } else { + if (gpxItem != null) { + analysis = gpxItem.analysis; + } + } + } + private void fetchTabTypes() { List tabTypeList = new ArrayList<>(); - tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_GENERAL); - if (gpxItem != null && gpxItem.analysis != null) { - if (gpxItem.analysis.hasElevationData) { + if (isShowCurrentTrack()) { + if (analysis != null && (analysis.hasElevationData || analysis.hasSpeedData)) { + tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_GENERAL); + } + } else { + tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_GENERAL); + } + if (analysis != null) { + if (analysis.hasElevationData) { tabTypeList.add(GPX_TAB_ITEM_ALTITUDE); } - if (gpxItem.analysis.isSpeedSpecified()) { + if (analysis.isSpeedSpecified()) { tabTypeList.add(GPX_TAB_ITEM_SPEED); } } @@ -123,11 +157,20 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid private List getDataSets(LineChart chart, GPXTabItemType tabType, LineGraphType firstType, LineGraphType secondType) { List dataSets = dataSetsMap.get(tabType); - if (dataSets == null && chart != null) { - GPXTrackAnalysis analysis = gpxItem.analysis; + boolean withoutGaps = true; + if (isShowCurrentTrack()) { + GPXFile gpxFile = displayHelper.getGpx(); + withoutGaps = !app.getSavingTrackHelper().getCurrentTrack().isJoinSegments() && gpxFile != null + && (Algorithms.isEmpty(gpxFile.tracks) || gpxFile.tracks.get(0).generalTrack); + } else if (gpxItem != null) { GpxDataItem gpxDataItem = displayHelper.getGpxDataItem(); - boolean calcWithoutGaps = gpxItem.isGeneralTrack() && gpxDataItem != null && !gpxDataItem.isJoinSegments(); - dataSets = GpxUiHelper.getDataSets(chart, app, analysis, firstType, secondType, calcWithoutGaps); + withoutGaps = gpxItem.isGeneralTrack() && gpxDataItem != null && !gpxDataItem.isJoinSegments(); + } + if (chart != null && analysis != null) { + dataSets = GpxUiHelper.getDataSets(chart, app, analysis, firstType, secondType, withoutGaps); + if (!Algorithms.isEmpty(dataSets)) { + dataSetsMap.remove(tabType); + } dataSetsMap.put(tabType, dataSets); } return dataSets; @@ -140,7 +183,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid if (ds != null && ds.size() > 0) { for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) { for (TrkSegment s : t.segments) { - if (s.points.size() > 0 && s.points.get(0).equals(gpxItem.analysis.locationStart)) { + if (s.points.size() > 0 && s.points.get(0).equals(analysis.locationStart)) { segment = s; break; } @@ -164,7 +207,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid if (gpxItem.chartAxisType == GPXDataSetAxisType.TIME) { float time = pos * 1000; for (WptPt p : segment.points) { - if (p.time - gpxItem.analysis.startTime >= time) { + if (p.time - analysis.startTime >= time) { wpt = p; break; } @@ -203,23 +246,20 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid public Object instantiateItem(@NonNull ViewGroup container, int position) { GPXTabItemType tabType = tabTypes[position]; View view = getViewForTab(container, tabType); - GPXFile gpxFile = displayHelper.getGpx(); - if (gpxFile != null && gpxItem != null) { - GPXTrackAnalysis analysis = gpxItem.analysis; - LineChart chart = view.findViewById(R.id.chart); - ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) chart.getLayoutParams(); - AndroidUtils.setMargins(lp, chartHMargin, lp.topMargin, chartHMargin, lp.bottomMargin); + LineChart chart = view.findViewById(R.id.chart); + ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) chart.getLayoutParams(); + AndroidUtils.setMargins(lp, chartHMargin, lp.topMargin, chartHMargin, lp.bottomMargin); + if (analysis != null) { setupChart(view, chart); - switch (tabType) { case GPX_TAB_ITEM_GENERAL: - setupGeneralTab(view, chart, analysis, gpxFile, position); + setupGeneralTab(view, chart, position); break; case GPX_TAB_ITEM_ALTITUDE: - setupAltitudeTab(view, chart, analysis, gpxFile, position); + setupAltitudeTab(view, chart, position); break; case GPX_TAB_ITEM_SPEED: - setupSpeedTab(view, chart, analysis, gpxFile, position); + setupSpeedTab(view, chart, position); break; } } @@ -252,10 +292,10 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid return view; } - private void setupSpeedTab(View view, LineChart chart, GPXTrackAnalysis analysis, GPXFile gpxFile, int position) { + private void setupSpeedTab(View view, LineChart chart, int position) { if (analysis != null && analysis.isSpeedSpecified()) { if (analysis.hasSpeedData) { - GpxUiHelper.setupGPXChart(app, chart, 4); + GpxUiHelper.setupGPXChart(app, chart, CHART_LABEL_COUNT); chart.setData(new LineData(getDataSets(chart, GPX_TAB_ITEM_SPEED, SPEED, null))); updateChart(chart); chart.setVisibility(View.VISIBLE); @@ -324,10 +364,10 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid }); } - private void setupAltitudeTab(View view, LineChart chart, GPXTrackAnalysis analysis, GPXFile gpxFile, int position) { + private void setupAltitudeTab(View view, LineChart chart, int position) { if (analysis != null) { if (analysis.hasElevationData) { - GpxUiHelper.setupGPXChart(app, chart, 4); + GpxUiHelper.setupGPXChart(app, chart, CHART_LABEL_COUNT); chart.setData(new LineData(getDataSets(chart, GPX_TAB_ITEM_ALTITUDE, ALTITUDE, SLOPE))); updateChart(chart); chart.setVisibility(View.VISIBLE); @@ -391,10 +431,10 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid } } - private void setupGeneralTab(View view, LineChart chart, GPXTrackAnalysis analysis, GPXFile gpxFile, int position) { + private void setupGeneralTab(View view, LineChart chart, int position) { if (analysis != null) { if (analysis.hasElevationData || analysis.hasSpeedData) { - GpxUiHelper.setupGPXChart(app, chart, 4); + GpxUiHelper.setupGPXChart(app, chart, CHART_LABEL_COUNT); chart.setData(new LineData(getDataSets(chart, GPXTabItemType.GPX_TAB_ITEM_GENERAL, ALTITUDE, SPEED))); updateChart(chart); chart.setVisibility(View.VISIBLE); @@ -632,10 +672,12 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid @Override public void tabStylesUpdated(View tabsContainer, int currentPosition) { - ViewGroup.MarginLayoutParams params = (MarginLayoutParams) tabsContainer.getLayoutParams(); - params.height = app.getResources().getDimensionPixelSize(!onlyGraphs ? R.dimen.dialog_button_height : R.dimen.context_menu_buttons_bottom_height); - tabsContainer.setLayoutParams(params); - UiUtilities.updateCustomRadioButtons(app, tabsContainer, nightMode, getCustomRadioButtonType(currentPosition)); + if (getCount() > 0) { + ViewGroup.MarginLayoutParams params = (MarginLayoutParams) tabsContainer.getLayoutParams(); + params.height = app.getResources().getDimensionPixelSize(!onlyGraphs ? R.dimen.dialog_button_height : R.dimen.context_menu_buttons_bottom_height); + tabsContainer.setLayoutParams(params); + UiUtilities.updateCustomRadioButtons(app, tabsContainer, nightMode, getCustomRadioButtonType(currentPosition)); + } } private CustomRadioButtonType getCustomRadioButtonType(int index) { @@ -667,22 +709,22 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid void updateJoinGapsInfo(View view, int position) { if (view != null) { - GPXTrackAnalysis analysis = gpxItem.analysis; GPXTabItemType tabType = tabTypes[position]; - boolean visible = gpxItem.isGeneralTrack() && analysis != null && tabType.equals(GPXTabItemType.GPX_TAB_ITEM_GENERAL); - AndroidUiHelper.updateVisibility(view.findViewById(R.id.gpx_join_gaps_container), visible); + boolean generalTrack = gpxItem.isGeneralTrack(); boolean joinSegments = displayHelper.isJoinSegments(); + boolean visible = generalTrack && analysis != null && tabType.equals(GPXTabItemType.GPX_TAB_ITEM_GENERAL); + AndroidUiHelper.updateVisibility(view.findViewById(R.id.gpx_join_gaps_container), visible); ((SwitchCompat) view.findViewById(R.id.gpx_join_gaps_switch)).setChecked(joinSegments); if (analysis != null) { if (tabType.equals(GPXTabItemType.GPX_TAB_ITEM_GENERAL)) { - float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; - float timeSpan = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeSpanWithoutGaps : analysis.timeSpan; + float totalDistance = !joinSegments && generalTrack ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; + float timeSpan = !joinSegments && generalTrack ? analysis.timeSpanWithoutGaps : analysis.timeSpan; ((TextView) view.findViewById(R.id.distance_text)).setText(OsmAndFormatter.getFormattedDistance(totalDistance, app)); ((TextView) view.findViewById(R.id.duration_text)).setText(Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled())); } else if (tabType.equals(GPX_TAB_ITEM_SPEED)) { - long timeMoving = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeMovingWithoutGaps : analysis.timeMoving; - float totalDistanceMoving = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceMovingWithoutGaps : analysis.totalDistanceMoving; + long timeMoving = !joinSegments && generalTrack ? analysis.timeMovingWithoutGaps : analysis.timeMoving; + float totalDistanceMoving = !joinSegments && generalTrack ? analysis.totalDistanceMovingWithoutGaps : analysis.totalDistanceMoving; ((TextView) view.findViewById(R.id.time_moving_text)).setText(Algorithms.formatDuration((int) (timeMoving / 1000), app.accessibilityEnabled())); ((TextView) view.findViewById(R.id.distance_text)).setText(OsmAndFormatter.getFormattedDistance(totalDistanceMoving, app)); @@ -693,17 +735,60 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid void updateChart(LineChart chart) { if (chart != null && !chart.isEmpty()) { - if (gpxItem.chartMatrix != null) { - chart.getViewPortHandler().refresh(new Matrix(gpxItem.chartMatrix), chart, true); - } - if (gpxItem.chartHighlightPos != -1) { - chart.highlightValue(gpxItem.chartHighlightPos, 0); + if (gpxItem != null) { + if (gpxItem.chartMatrix != null) { + chart.getViewPortHandler().refresh(new Matrix(gpxItem.chartMatrix), chart, true); + } + if (gpxItem.chartHighlightPos != -1) { + chart.highlightValue(gpxItem.chartHighlightPos, 0); + } } else { chart.highlightValue(null); } } } + public boolean isTabsVisible() { + GPXFile gpxFile = displayHelper.getGpx(); + if (gpxFile != null && getCount() > 0 && views.size() > 0) { + for (int i = 0; i < getCount(); i++) { + LineChart lc = getViewAtPosition(i).findViewById(R.id.chart); + if (!lc.isEmpty() && !gpxFile.isEmpty()) { + return true; + } + } + } + return false; + } + + public void updateGraph(int position) { + updateAnalysis(); + fetchTabTypes(); + if (getCount() > 0 && views.size() > 0) { + LineGraphType firstType = tabTypes[position] == GPX_TAB_ITEM_SPEED ? SPEED : ALTITUDE; + LineGraphType secondType = null; + if (tabTypes[position] == GPX_TAB_ITEM_ALTITUDE) { + secondType = SLOPE; + } else if (tabTypes[position] == GPX_TAB_ITEM_GENERAL) { + secondType = SPEED; + } + LineChart chart = getViewAtPosition(position).findViewById(R.id.chart); + List dataSets = getDataSets(chart, tabTypes[position], firstType, secondType); + boolean isEmptyDataSets = Algorithms.isEmpty(dataSets); + AndroidUiHelper.updateVisibility(chart, !isEmptyDataSets); + chart.clear(); + if (!isEmptyDataSets) { + chart.setData(new LineData(dataSets)); + } + if (chart.getAxisRight().getLabelCount() != CHART_LABEL_COUNT + || chart.getAxisLeft().getLabelCount() != CHART_LABEL_COUNT) { + GpxUiHelper.setupGPXChart(app, chart, CHART_LABEL_COUNT); + } + updateChart(chart); + } + notifyDataSetChanged(); + } + private TrkSegment getTrkSegment() { for (Track track : gpxItem.group.getGpx().tracks) { if (!track.generalTrack && !gpxItem.isGeneralTrack() || track.generalTrack && gpxItem.isGeneralTrack()) { diff --git a/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java b/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java index 0c544ca0d4..35ee1e08bb 100644 --- a/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java +++ b/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java @@ -30,6 +30,7 @@ import net.osmand.plus.R; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; +import net.osmand.plus.myplaces.GPXTabItemType; import net.osmand.plus.myplaces.SegmentActionsListener; import net.osmand.plus.widgets.TextViewEx; import net.osmand.util.Algorithms; @@ -44,15 +45,12 @@ import java.util.Date; import java.util.List; import static net.osmand.plus.liveupdates.LiveUpdatesFragment.getDefaultIconColorId; +import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_SPEED; public class GpxBlockStatisticsBuilder { private static final Log LOG = PlatformUtil.getLog(GpxBlockStatisticsBuilder.class); private static final int BLOCKS_UPDATE_INTERVAL = 1000; - public static final String INIT_BLOCKS_BASE = "init_blocks_base"; - public static final String INIT_BLOCKS_GENERAL = "init_blocks_general"; - public static final String INIT_BLOCKS_ALTITUDE = "init_blocks_altitude"; - public static final String INIT_BLOCKS_SPEED = "init_blocks_speed"; private final OsmandApplication app; private final boolean nightMode; @@ -64,7 +62,7 @@ public class GpxBlockStatisticsBuilder { private BlockStatisticsAdapter adapter; private final List items = new ArrayList<>(); private boolean blocksClickable = true; - private String initBlocksKey = INIT_BLOCKS_BASE; + private GPXTabItemType tabItem = null; private final Handler handler = new Handler(); private Runnable updatingItems; @@ -88,8 +86,8 @@ public class GpxBlockStatisticsBuilder { this.blocksView = blocksView; } - public void setInitBlocksKey(String initBlocksKey) { - this.initBlocksKey = initBlocksKey; + public void setTabItem(GPXTabItemType tabItem) { + this.tabItem = tabItem; } @Nullable @@ -133,6 +131,11 @@ public class GpxBlockStatisticsBuilder { } } + public void restartUpdatingStatBlocks() { + stopUpdatingStatBlocks(); + runUpdatingStatBlocksIfNeeded(); + } + public void initItems() { GPXFile gpxFile = getGPXFile(); if (app == null || gpxFile == null) { @@ -154,60 +157,59 @@ public class GpxBlockStatisticsBuilder { } items.clear(); if (analysis != null) { - switch (initBlocksKey) { - case INIT_BLOCKS_GENERAL: { - float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; - float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan; - Date start = new Date(analysis.startTime); - Date end = new Date(analysis.endTime); - prepareDataDistance(totalDistance); - prepareDataTimeSpan(timeSpan); - prepareDataStartTime(start); - prepareDataEndTime(end); - break; - } - case INIT_BLOCKS_ALTITUDE: { - String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app); - String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app); - String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); - String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); - prepareDataAverageAltitude(); - prepareDataAltitudeRange(min, max); - prepareDataAscent(asc); - prepareDataDescent(desc); - break; - } - case INIT_BLOCKS_SPEED: { - String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); - String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); - long timeMoving = withoutGaps ? analysis.timeMovingWithoutGaps : analysis.timeMoving; - float totalDistanceMoving = withoutGaps ? analysis.totalDistanceMovingWithoutGaps : analysis.totalDistanceMoving; - prepareDataAverageSpeed(avg); - prepareDataMaximumSpeed(max); - prepareDataTimeMoving(timeMoving); - prepareDataDistanceCorrected(totalDistanceMoving); - break; - } - default: - case INIT_BLOCKS_BASE: { - float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; - String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); - String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); - String minElevation = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app); - String maxElevation = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app); - String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); - String maxSpeed = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); - float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan; - long timeMoving = withoutGaps ? analysis.timeMovingWithoutGaps : analysis.timeMoving; - prepareDataDistance(totalDistance); - prepareDataAscent(asc); - prepareDataDescent(desc); - prepareDataAltitudeRange(minElevation, maxElevation); - prepareDataAverageSpeed(avg); - prepareDataMaximumSpeed(maxSpeed); - prepareDataTimeSpan(timeSpan); - prepareDataTimeMoving(timeMoving); - break; + if (tabItem == null) { + float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; + String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); + String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); + String minElevation = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app); + String maxElevation = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app); + String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); + String maxSpeed = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); + float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan; + long timeMoving = withoutGaps ? analysis.timeMovingWithoutGaps : analysis.timeMoving; + prepareDataDistance(totalDistance); + prepareDataAscent(asc); + prepareDataDescent(desc); + prepareDataAltitudeRange(minElevation, maxElevation); + prepareDataAverageSpeed(avg); + prepareDataMaximumSpeed(maxSpeed); + prepareDataTimeSpan(timeSpan); + prepareDataTimeMoving(timeMoving); + } else { + switch (tabItem) { + case GPX_TAB_ITEM_GENERAL: { + float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; + float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan; + Date start = new Date(analysis.startTime); + Date end = new Date(analysis.endTime); + prepareDataDistance(totalDistance); + prepareDataTimeSpan(timeSpan); + prepareDataStartTime(start); + prepareDataEndTime(end); + break; + } + case GPX_TAB_ITEM_ALTITUDE: { + String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app); + String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app); + String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); + String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); + prepareDataAverageAltitude(); + prepareDataAltitudeRange(min, max); + prepareDataAscent(asc); + prepareDataDescent(desc); + break; + } + case GPX_TAB_ITEM_SPEED: { + String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); + String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); + long timeMoving = withoutGaps ? analysis.timeMovingWithoutGaps : analysis.timeMoving; + float totalDistanceMoving = withoutGaps ? analysis.totalDistanceMovingWithoutGaps : analysis.totalDistanceMoving; + prepareDataAverageSpeed(avg); + prepareDataMaximumSpeed(max); + prepareDataTimeMoving(timeMoving); + prepareDataDistanceCorrected(totalDistanceMoving); + break; + } } } } @@ -251,9 +253,9 @@ public class GpxBlockStatisticsBuilder { } public void prepareDataTimeMoving(long timeMoving) { - prepareData(app.getString(initBlocksKey.equals(INIT_BLOCKS_SPEED) ? R.string.shared_string_time_moving : R.string.moving_time), + prepareData(app.getString(tabItem == GPX_TAB_ITEM_SPEED ? R.string.shared_string_time_moving : R.string.moving_time), Algorithms.formatDuration((int) (timeMoving / 1000), app.accessibilityEnabled()), - initBlocksKey.equals(INIT_BLOCKS_SPEED) ? R.drawable.ic_action_time_span_16 : R.drawable.ic_action_time_moving_16, + tabItem == GPX_TAB_ITEM_SPEED ? R.drawable.ic_action_time_span_16 : R.drawable.ic_action_time_moving_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME_MOVING); } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index b2d3aaa7dd..ef2bd196a7 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -866,7 +866,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (FileUtils.removeGpxFile(app, new File((gpxFile.path)))) { + if (FileUtils.removeGpxFile(app, new File(gpxFile.path))) { dismiss(); } }