Fix rotation in track activity

This commit is contained in:
PavelRatushny 2017-07-26 13:38:21 +03:00
parent f949b7cd23
commit db404f8c53
2 changed files with 67 additions and 66 deletions

View file

@ -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<GpxDisplayGroup> 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<GpxDisplayGroup> 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();
}

View file

@ -710,29 +710,28 @@ public class TrackSegmentFragment extends OsmAndListFragment {
}
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
if (getTrackActivity() == null) {
return null;
}
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
List<GpxDisplayGroup> groups = new ArrayList<>();
for (GpxDisplayGroup group : result) {
boolean add = hasFilterType(group.getType());
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
Iterator<GpxDisplayItem> 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<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
for (GpxDisplayGroup group : result) {
boolean add = hasFilterType(group.getType());
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
Iterator<GpxDisplayItem> 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<GpxDisplayItem> flatten(List<GpxDisplayGroup> groups) {