Fix TrackActivity
This commit is contained in:
parent
09177f90b2
commit
0b6a7401b5
2 changed files with 91 additions and 97 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();
|
||||||
}
|
}
|
||||||
|
@ -233,33 +227,33 @@ public class TrackActivity extends TabActivity {
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
int backStackEntriesCount = getSupportFragmentManager().getBackStackEntryCount();
|
int backStackEntriesCount = getSupportFragmentManager().getBackStackEntryCount();
|
||||||
if (backStackEntriesCount > 0) {
|
if (backStackEntriesCount > 0) {
|
||||||
FragmentManager.BackStackEntry backStackEntry = getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1);
|
FragmentManager.BackStackEntry backStackEntry = getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1);
|
||||||
if (backStackEntry.getName().equals(SplitSegmentFragment.TAG)) {
|
if (backStackEntry.getName().equals(SplitSegmentFragment.TAG)) {
|
||||||
for (WeakReference<Fragment> f : fragList) {
|
for (WeakReference<Fragment> f : fragList) {
|
||||||
Fragment frag = f.get();
|
Fragment frag = f.get();
|
||||||
if (frag instanceof TrackSegmentFragment) {
|
if (frag instanceof TrackSegmentFragment) {
|
||||||
((TrackSegmentFragment) frag).updateSplitView();
|
((TrackSegmentFragment) frag).updateSplitView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
getSupportFragmentManager().popBackStack();
|
||||||
|
if (isHavingWayPoints() || isHavingRoutePoints()) {
|
||||||
|
getSlidingTabLayout().setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
getSupportFragmentManager().popBackStack();
|
|
||||||
if (isHavingWayPoints() || isHavingRoutePoints()) {
|
|
||||||
getSlidingTabLayout().setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
if (getIntent().hasExtra(MapActivity.INTENT_KEY_PARENT_MAP_ACTIVITY)) {
|
||||||
if (getIntent().hasExtra(MapActivity.INTENT_KEY_PARENT_MAP_ACTIVITY)) {
|
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
||||||
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
final Intent favorites = new Intent(this, appCustomization.getFavoritesActivity());
|
||||||
final Intent favorites = new Intent(this, appCustomization.getFavoritesActivity());
|
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.GPX_TAB);
|
||||||
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.GPX_TAB);
|
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
startActivity(favorites);
|
||||||
startActivity(favorites);
|
}
|
||||||
}
|
finish();
|
||||||
finish();
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -287,11 +281,11 @@ public class TrackActivity extends TabActivity {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isHavingWayPoints(){
|
boolean isHavingWayPoints() {
|
||||||
return getGpx() != null && getGpx().hasWptPt();
|
return getGpx() != null && getGpx().hasWptPt();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isHavingRoutePoints(){
|
boolean isHavingRoutePoints() {
|
||||||
return getGpx() != null && getGpx().hasRtePt();
|
return getGpx() != null && getGpx().hasRtePt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,4 +297,3 @@ public class TrackActivity extends TabActivity {
|
||||||
return gpxDataItem;
|
return gpxDataItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -710,29 +710,28 @@ 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<>();
|
||||||
for (GpxDisplayGroup group : result) {
|
if (getTrackActivity() != null) {
|
||||||
boolean add = hasFilterType(group.getType());
|
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
|
||||||
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
|
for (GpxDisplayGroup group : result) {
|
||||||
Iterator<GpxDisplayItem> item = group.getModifiableList().iterator();
|
boolean add = hasFilterType(group.getType());
|
||||||
while (item.hasNext()) {
|
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
|
||||||
GpxDisplayItem it2 = item.next();
|
Iterator<GpxDisplayItem> item = group.getModifiableList().iterator();
|
||||||
if (it2.analysis != null && it2.analysis.totalDistance < 100) {
|
while (item.hasNext()) {
|
||||||
item.remove();
|
GpxDisplayItem it2 = item.next();
|
||||||
|
if (it2.analysis != null && it2.analysis.totalDistance < 100) {
|
||||||
|
item.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group.getModifiableList().isEmpty()) {
|
||||||
|
add = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (group.getModifiableList().isEmpty()) {
|
if (add) {
|
||||||
add = false;
|
groups.add(group);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (add) {
|
|
||||||
groups.add(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
@ -746,7 +745,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
adapter.setNotifyOnChange(true);
|
adapter.setNotifyOnChange(true);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
updateHeader();
|
if (getActivity() != null) {
|
||||||
|
updateHeader();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<GpxDisplayItem> flatten(List<GpxDisplayGroup> groups) {
|
protected List<GpxDisplayItem> flatten(List<GpxDisplayGroup> groups) {
|
||||||
|
|
Loading…
Reference in a new issue