From f949b7cd23221529248da38186b7b2b27ab7fd93 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 26 Jul 2017 11:43:01 +0300 Subject: [PATCH 1/3] Revert track activity --- OsmAnd/src/net/osmand/plus/activities/TrackActivity.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java index bf918c96bb..b0286a90e6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java @@ -76,12 +76,6 @@ public class TrackActivity extends TabActivity { actionBar.setElevation(0); } setContentView(R.layout.tab_content); - } - - @Override - protected void onStart() { - super.onStart(); - stopped = false; slidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs); if (slidingTabLayout != null) { From db404f8c53b22b318ebd1580d47cd3328e1f2489 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 26 Jul 2017 13:38:21 +0300 Subject: [PATCH 2/3] Fix rotation in track activity --- .../osmand/plus/activities/TrackActivity.java | 94 +++++++++---------- .../plus/myplaces/TrackSegmentFragment.java | 39 ++++---- 2 files changed, 67 insertions(+), 66 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java index b0286a90e6..2a5e51e9fd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java @@ -76,7 +76,54 @@ public class TrackActivity extends TabActivity { actionBar.setElevation(0); } setContentView(R.layout.tab_content); + } + protected void setGpxDataItem(GpxDataItem gpxDataItem) { + this.gpxDataItem = gpxDataItem; + } + + protected void setGpx(GPXFile result) { + this.gpxFile = result; + if (file == null) { + this.gpxFile = getMyApplication().getSavingTrackHelper().getCurrentGpx(); + } + } + + public List getGpxFile(boolean useDisplayGroups) { + if (gpxFile == null) { + return new ArrayList<>(); + } + if (gpxFile.modifiedTime != modifiedTime) { + modifiedTime = gpxFile.modifiedTime; + GpxSelectionHelper selectedGpxHelper = ((OsmandApplication) getApplication()).getSelectedGpxHelper(); + displayGroups = selectedGpxHelper.collectDisplayGroups(gpxFile); + originalGroups.clear(); + for (GpxDisplayGroup g : displayGroups) { + originalGroups.add(g.cloneInstance()); + } + if (file != null) { + SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path); + if (sf != null && file != null && sf.getDisplayGroups() != null) { + displayGroups = sf.getDisplayGroups(); + } + } + } + if (useDisplayGroups) { + return displayGroups; + } else { + return originalGroups; + } + } + + @Override + public void onAttachFragment(Fragment fragment) { + fragList.add(new WeakReference<>(fragment)); + } + + @Override + protected void onResume() { + super.onResume(); + stopped = false; slidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs); if (slidingTabLayout != null) { slidingTabLayout.setShouldExpand(true); @@ -151,53 +198,6 @@ public class TrackActivity extends TabActivity { } } - protected void setGpxDataItem(GpxDataItem gpxDataItem) { - this.gpxDataItem = gpxDataItem; - } - - protected void setGpx(GPXFile result) { - this.gpxFile = result; - if (file == null) { - this.gpxFile = getMyApplication().getSavingTrackHelper().getCurrentGpx(); - } - } - - public List getGpxFile(boolean useDisplayGroups) { - if (gpxFile == null) { - return new ArrayList<>(); - } - if (gpxFile.modifiedTime != modifiedTime) { - modifiedTime = gpxFile.modifiedTime; - GpxSelectionHelper selectedGpxHelper = ((OsmandApplication) getApplication()).getSelectedGpxHelper(); - displayGroups = selectedGpxHelper.collectDisplayGroups(gpxFile); - originalGroups.clear(); - for (GpxDisplayGroup g : displayGroups) { - originalGroups.add(g.cloneInstance()); - } - if (file != null) { - SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path); - if (sf != null && file != null && sf.getDisplayGroups() != null) { - displayGroups = sf.getDisplayGroups(); - } - } - } - if (useDisplayGroups) { - return displayGroups; - } else { - return originalGroups; - } - } - - @Override - public void onAttachFragment(Fragment fragment) { - fragList.add(new WeakReference<>(fragment)); - } - - @Override - protected void onResume() { - super.onResume(); - } - public OsmandApplication getMyApplication() { return (OsmandApplication) getApplication(); } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index 74f2273db3..f10023cb5a 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -710,29 +710,28 @@ public class TrackSegmentFragment extends OsmAndListFragment { } private List filterGroups(boolean useDisplayGroups) { - if (getTrackActivity() == null) { - return null; - } - List result = getTrackActivity().getGpxFile(useDisplayGroups); List groups = new ArrayList<>(); - for (GpxDisplayGroup group : result) { - boolean add = hasFilterType(group.getType()); - if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) { - Iterator item = group.getModifiableList().iterator(); - while (item.hasNext()) { - GpxDisplayItem it2 = item.next(); - if (it2.analysis != null && it2.analysis.totalDistance < 100) { - item.remove(); + if (getTrackActivity() != null) { + List result = getTrackActivity().getGpxFile(useDisplayGroups); + for (GpxDisplayGroup group : result) { + boolean add = hasFilterType(group.getType()); + if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) { + Iterator item = group.getModifiableList().iterator(); + while (item.hasNext()) { + GpxDisplayItem it2 = item.next(); + if (it2.analysis != null && it2.analysis.totalDistance < 100) { + item.remove(); + } + } + if (group.getModifiableList().isEmpty()) { + add = false; } } - if (group.getModifiableList().isEmpty()) { - add = false; + if (add) { + groups.add(group); } - } - if (add) { - groups.add(group); - } + } } return groups; } @@ -746,7 +745,9 @@ public class TrackSegmentFragment extends OsmAndListFragment { } adapter.setNotifyOnChange(true); adapter.notifyDataSetChanged(); - updateHeader(); + if (getActivity() != null) { + updateHeader(); + } } protected List flatten(List groups) { From fbab53ae7d3dca513eafa0706b6d275e4eedea85 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 26 Jul 2017 13:50:38 +0300 Subject: [PATCH 3/3] Fix filter groups --- .../plus/myplaces/SplitSegmentFragment.java | 38 +++++++++---------- .../plus/myplaces/TrackSegmentFragment.java | 3 -- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java index 231e4ef379..5a39560aeb 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java @@ -322,29 +322,28 @@ public class SplitSegmentFragment extends OsmAndListFragment { } private List filterGroups(boolean useDisplayGroups) { - if (getTrackActivity() == null) { - return null; - } - List result = getTrackActivity().getGpxFile(useDisplayGroups); List groups = new ArrayList<>(); - for (GpxDisplayGroup group : result) { - boolean add = hasFilterType(group.getType()); - if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) { - Iterator item = group.getModifiableList().iterator(); - while (item.hasNext()) { - GpxDisplayItem it2 = item.next(); - if (it2.analysis != null && it2.analysis.totalDistance < 100) { - item.remove(); + if (getTrackActivity() != null) { + List result = getTrackActivity().getGpxFile(useDisplayGroups); + for (GpxDisplayGroup group : result) { + boolean add = hasFilterType(group.getType()); + if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) { + Iterator item = group.getModifiableList().iterator(); + while (item.hasNext()) { + GpxDisplayItem it2 = item.next(); + if (it2.analysis != null && it2.analysis.totalDistance < 100) { + item.remove(); + } + } + if (group.getModifiableList().isEmpty()) { + add = false; } } - if (group.getModifiableList().isEmpty()) { - add = false; + if (add) { + groups.add(group); } - } - if (add) { - groups.add(group); - } + } } return groups; } @@ -657,9 +656,6 @@ public class SplitSegmentFragment extends OsmAndListFragment { } if (mSelectedGpxFile != null) { List groups = getDisplayGroups(); - if (groups == null) { - return; - } mSelectedGpxFile.setDisplayGroups(groups); } updateContent(); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index f10023cb5a..df7be4a354 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -1542,9 +1542,6 @@ public class TrackSegmentFragment extends OsmAndListFragment { } if (mSelectedGpxFile != null) { List groups = getDisplayGroups(); - if (groups == null) { - return; - } mSelectedGpxFile.setDisplayGroups(groups); } if (mFragment.isVisible()) {