Merge pull request #4206 from osmandapp/fix_crash_in_track_activity
Fix bugs track activity
This commit is contained in:
commit
dcb50e7cfc
3 changed files with 82 additions and 94 deletions
|
@ -78,11 +78,52 @@ public class TrackActivity extends TabActivity {
|
||||||
setContentView(R.layout.tab_content);
|
setContentView(R.layout.tab_content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected void setGpxDataItem(GpxDataItem gpxDataItem) {
|
||||||
protected void onStart() {
|
this.gpxDataItem = gpxDataItem;
|
||||||
super.onStart();
|
}
|
||||||
stopped = false;
|
|
||||||
|
|
||||||
|
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);
|
slidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
|
||||||
if (slidingTabLayout != null) {
|
if (slidingTabLayout != null) {
|
||||||
slidingTabLayout.setShouldExpand(true);
|
slidingTabLayout.setShouldExpand(true);
|
||||||
|
@ -157,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() {
|
public OsmandApplication getMyApplication() {
|
||||||
return (OsmandApplication) getApplication();
|
return (OsmandApplication) getApplication();
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,11 +322,9 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
|
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
|
||||||
if (getTrackActivity() == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
|
|
||||||
List<GpxDisplayGroup> groups = new ArrayList<>();
|
List<GpxDisplayGroup> groups = new ArrayList<>();
|
||||||
|
if (getTrackActivity() != null) {
|
||||||
|
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
|
||||||
for (GpxDisplayGroup group : result) {
|
for (GpxDisplayGroup group : result) {
|
||||||
boolean add = hasFilterType(group.getType());
|
boolean add = hasFilterType(group.getType());
|
||||||
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
|
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
|
||||||
|
@ -346,6 +344,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,9 +656,6 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
if (mSelectedGpxFile != null) {
|
if (mSelectedGpxFile != null) {
|
||||||
List<GpxDisplayGroup> groups = getDisplayGroups();
|
List<GpxDisplayGroup> groups = getDisplayGroups();
|
||||||
if (groups == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mSelectedGpxFile.setDisplayGroups(groups);
|
mSelectedGpxFile.setDisplayGroups(groups);
|
||||||
}
|
}
|
||||||
updateContent();
|
updateContent();
|
||||||
|
|
|
@ -710,11 +710,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
|
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
|
||||||
if (getTrackActivity() == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
|
|
||||||
List<GpxDisplayGroup> groups = new ArrayList<>();
|
List<GpxDisplayGroup> groups = new ArrayList<>();
|
||||||
|
if (getTrackActivity() != null) {
|
||||||
|
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
|
||||||
for (GpxDisplayGroup group : result) {
|
for (GpxDisplayGroup group : result) {
|
||||||
boolean add = hasFilterType(group.getType());
|
boolean add = hasFilterType(group.getType());
|
||||||
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
|
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
|
||||||
|
@ -734,6 +732,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,8 +745,10 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
adapter.setNotifyOnChange(true);
|
adapter.setNotifyOnChange(true);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
if (getActivity() != null) {
|
||||||
updateHeader();
|
updateHeader();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected List<GpxDisplayItem> flatten(List<GpxDisplayGroup> groups) {
|
protected List<GpxDisplayItem> flatten(List<GpxDisplayGroup> groups) {
|
||||||
ArrayList<GpxDisplayItem> list = new ArrayList<>();
|
ArrayList<GpxDisplayItem> list = new ArrayList<>();
|
||||||
|
@ -1541,9 +1542,6 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
if (mSelectedGpxFile != null) {
|
if (mSelectedGpxFile != null) {
|
||||||
List<GpxDisplayGroup> groups = getDisplayGroups();
|
List<GpxDisplayGroup> groups = getDisplayGroups();
|
||||||
if (groups == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mSelectedGpxFile.setDisplayGroups(groups);
|
mSelectedGpxFile.setDisplayGroups(groups);
|
||||||
}
|
}
|
||||||
if (mFragment.isVisible()) {
|
if (mFragment.isVisible()) {
|
||||||
|
|
Loading…
Reference in a new issue