From d227e34b598a3ef7179352e58cff90a6e6bfa247 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 12 Jul 2017 10:36:48 +0300 Subject: [PATCH] Fix update header --- .../plus/myplaces/SplitSegmentFragment.java | 22 +++++------ .../plus/myplaces/TrackSegmentFragment.java | 38 ++++++++++--------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java index 0894b039a1..125f9d29f1 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java @@ -73,13 +73,13 @@ public class SplitSegmentFragment extends OsmAndListFragment { getListView().setBackgroundColor(getResources().getColor( getMyApplication().getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light : R.color.ctx_menu_info_view_bg_dark)); - getMyActivity().onAttachFragment(this); + getTrackActivity().onAttachFragment(this); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); - getMyActivity().getClearToolbar(false); + getTrackActivity().getClearToolbar(false); } @Override @@ -162,7 +162,7 @@ public class SplitSegmentFragment extends OsmAndListFragment { popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP); popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f)); popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f)); - popup.setAdapter(new ArrayAdapter<>(getMyActivity(), + popup.setAdapter(new ArrayAdapter<>(getTrackActivity(), R.layout.popup_list_text_item, options)); popup.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -232,10 +232,10 @@ public class SplitSegmentFragment extends OsmAndListFragment { } private GPXUtilities.GPXFile getGpx() { - return getMyActivity().getGpx(); + return getTrackActivity().getGpx(); } - public TrackActivity getMyActivity() { + public TrackActivity getTrackActivity() { return (TrackActivity) getActivity(); } @@ -302,10 +302,10 @@ public class SplitSegmentFragment extends OsmAndListFragment { } private List filterGroups(boolean useDisplayGroups) { - if (getMyActivity() == null) { + if (getTrackActivity() == null) { return null; } - List result = getMyActivity().getGpxFile(useDisplayGroups); + List result = getTrackActivity().getGpxFile(useDisplayGroups); List groups = new ArrayList<>(); for (GpxDisplayGroup group : result) { boolean add = hasFilterType(group.getType()); @@ -330,7 +330,7 @@ public class SplitSegmentFragment extends OsmAndListFragment { } private List getSplitSegments() { - List result = getMyActivity().getGpxFile(true); + List result = getTrackActivity().getGpxFile(true); List splitSegments = new ArrayList<>(); if (result != null && result.size() > 0) { if (result.get(0).isSplitDistance() || result.get(0).isSplitTime()) { @@ -341,7 +341,7 @@ public class SplitSegmentFragment extends OsmAndListFragment { } private GpxDisplayItem getOverviewSegment() { - List result = getMyActivity().getGpxFile(false); + List result = getTrackActivity().getGpxFile(false); GpxDisplayItem overviewSegment = null; if (result.size() > 0) { overviewSegment = result.get(0).getModifiableList().get(0); @@ -383,7 +383,7 @@ public class SplitSegmentFragment extends OsmAndListFragment { public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { GpxDisplayItem currentGpxDisplayItem = getItem(position); if (convertView == null) { - convertView = getMyActivity().getLayoutInflater().inflate(R.layout.gpx_split_segment_fragment, parent, false); + convertView = getTrackActivity().getLayoutInflater().inflate(R.layout.gpx_split_segment_fragment, parent, false); } convertView.setOnClickListener(null); TextView overviewTextView = (TextView) convertView.findViewById(R.id.overview_text); @@ -611,7 +611,7 @@ public class SplitSegmentFragment extends OsmAndListFragment { SplitTrackAsyncTask(@Nullable GpxSelectionHelper.SelectedGpxFile selectedGpxFile, List groups) { mSelectedGpxFile = selectedGpxFile; - mActivity = getMyActivity(); + mActivity = getTrackActivity(); this.groups = groups; } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index 66749225d1..2c390f47c4 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -187,7 +187,7 @@ public class TrackSegmentFragment extends OsmAndListFragment { return view; } - public TrackActivity getMyActivity() { + public TrackActivity getTrackActivity() { return (TrackActivity) getActivity(); } @@ -203,7 +203,7 @@ public class TrackSegmentFragment extends OsmAndListFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); - getMyActivity().getClearToolbar(false); + getTrackActivity().getClearToolbar(false); if (getGpx() != null && getGpx().path != null && !getGpx().showCurrentTrack) { MenuItem item = menu.add(R.string.shared_string_share).setIcon(R.drawable.ic_action_gshare_dark) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @@ -236,11 +236,11 @@ public class TrackSegmentFragment extends OsmAndListFragment { } private GPXFile getGpx() { - return getMyActivity().getGpx(); + return getTrackActivity().getGpx(); } private GpxDataItem getGpxDataItem() { - return getMyActivity().getGpxDataItem(); + return getTrackActivity().getGpxDataItem(); } private void startHandler() { @@ -363,11 +363,17 @@ public class TrackSegmentFragment extends OsmAndListFragment { } }); - boolean hasPath = getGpx() != null && getGpx().showCurrentTrack; + boolean hasPath = false; + if (getGpx() != null) { + if (getGpx().showCurrentTrack && adapter.getCount() > 0) { + hasPath = false; + } else if (getGpx().tracks.size() > 0 || getGpx().routes.size() > 0) { + hasPath = true; + } + } if (rotatedTileBox == null || mapBitmap == null || mapTrackBitmap == null) { QuadRect rect = getRect(); if (rect.left != 0 && rect.top != 0) { - hasPath = getGpx() != null && (getGpx().tracks.size() > 0 || getGpx().routes.size() > 0); progressBar.setVisibility(View.VISIBLE); double clat = rect.bottom / 2 + rect.top / 2; @@ -421,7 +427,7 @@ public class TrackSegmentFragment extends OsmAndListFragment { } if (hasPath) { - if (getGpx() != null && !getGpx().showCurrentTrack && adapter.getCount() > 0) { + if (getGpx() != null && !getGpx().showCurrentTrack) { prepareSplitIntervalAdapterData(); setupSplitIntervalView(splitIntervalView); updateSplitIntervalView(splitIntervalView); @@ -435,7 +441,7 @@ public class TrackSegmentFragment extends OsmAndListFragment { popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP); popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f)); popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f)); - popup.setAdapter(new ArrayAdapter<>(getMyActivity(), + popup.setAdapter(new ArrayAdapter<>(getTrackActivity(), R.layout.popup_list_text_item, options)); popup.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -681,10 +687,10 @@ public class TrackSegmentFragment extends OsmAndListFragment { } private List filterGroups(boolean useDisplayGroups) { - if (getMyActivity() == null) { + if (getTrackActivity() == null) { return null; } - List result = getMyActivity().getGpxFile(useDisplayGroups); + List result = getTrackActivity().getGpxFile(useDisplayGroups); List groups = new ArrayList<>(); for (GpxDisplayGroup group : result) { boolean add = hasFilterType(group.getType()); @@ -718,10 +724,6 @@ public class TrackSegmentFragment extends OsmAndListFragment { adapter.setNotifyOnChange(true); adapter.notifyDataSetChanged(); updateHeader(); - if (getGpx() != null && (getGpx().tracks.size() > 0 || getGpx().routes.size() > 0)) { - (headerView.findViewById(R.id.split_color_view)).setVisibility(View.VISIBLE); - (headerView.findViewById(R.id.divider)).setVisibility(View.VISIBLE); - } } protected List flatten(List groups) { @@ -813,7 +815,7 @@ public class TrackSegmentFragment extends OsmAndListFragment { WrapContentHeightViewPager pager; boolean create = false; if (row == null) { - LayoutInflater inflater = getMyActivity().getLayoutInflater(); + LayoutInflater inflater = getTrackActivity().getLayoutInflater(); row = inflater.inflate(R.layout.gpx_list_item_tab_content, parent, false); boolean light = app.getSettings().isLightContent(); @@ -1490,12 +1492,12 @@ public class TrackSegmentFragment extends OsmAndListFragment { } void openSplitIntervalScreen() { - getMyActivity().getSupportFragmentManager() + getTrackActivity().getSupportFragmentManager() .beginTransaction() .replace(R.id.track_activity_layout, new SplitSegmentFragment()) .addToBackStack(SplitSegmentFragment.TAG) .commit(); - getMyActivity().getSlidingTabLayout().setVisibility(View.GONE); + getTrackActivity().getSlidingTabLayout().setVisibility(View.GONE); } private class SplitTrackAsyncTask extends AsyncTask { @@ -1509,7 +1511,7 @@ public class TrackSegmentFragment extends OsmAndListFragment { SplitTrackAsyncTask(@Nullable SelectedGpxFile selectedGpxFile, List groups) { mSelectedGpxFile = selectedGpxFile; mFragment = TrackSegmentFragment.this; - mActivity = getMyActivity(); + mActivity = getTrackActivity(); this.groups = groups; }